loading
Generated 2025-08-02T06:05:00+05:30

All Files ( 85.12% covered at 7.07 hits/line )

523 files in total.
11412 relevant lines, 9714 lines covered and 1698 lines missed. ( 85.12% )
819 total branches, 123 branches covered and 696 branches missed. ( 15.02% )
File % covered Lines Relevant Lines Lines covered Lines missed Avg. Hits / Line Branch Coverage Branches Covered branches Missed branches
lib/ai/chat.rb 44.44 % 286 126 56 70 0.77 16.67 % 60 10 50
lib/ai/response.rb 50.00 % 12 8 4 4 0.50 100.00 % 0 0 0
openai-ruby/lib/openai.rb 99.81 % 549 537 536 1 1.00 50.00 % 2 1 1
openai-ruby/lib/openai/client.rb 98.28 % 167 58 57 1 1.48 50.00 % 10 5 5
openai-ruby/lib/openai/errors.rb 78.79 % 253 66 52 14 1.03 15.38 % 13 2 11
openai-ruby/lib/openai/file_part.rb 47.37 % 55 19 9 10 0.47 0.00 % 11 0 11
openai-ruby/lib/openai/helpers/streaming/events.rb 100.00 % 23 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/helpers/streaming/response_stream.rb 20.19 % 232 104 21 83 0.20 0.00 % 39 0 39
openai-ruby/lib/openai/helpers/structured_output.rb 100.00 % 16 3 3 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/helpers/structured_output/array_of.rb 50.00 % 49 16 8 8 0.50 0.00 % 4 0 4
openai-ruby/lib/openai/helpers/structured_output/base_model.rb 39.29 % 78 28 11 17 0.39 0.00 % 7 0 7
openai-ruby/lib/openai/helpers/structured_output/boolean.rb 100.00 % 28 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/helpers/structured_output/enum_of.rb 52.38 % 63 21 11 10 0.52 0.00 % 12 0 12
openai-ruby/lib/openai/helpers/structured_output/json_schema_converter.rb 21.21 % 186 66 14 52 0.21 0.00 % 30 0 30
openai-ruby/lib/openai/helpers/structured_output/parsed_json.rb 75.00 % 39 8 6 2 0.75 0.00 % 2 0 2
openai-ruby/lib/openai/helpers/structured_output/union_of.rb 43.33 % 74 30 13 17 0.87 16.67 % 12 2 10
openai-ruby/lib/openai/internal.rb 77.78 % 20 9 7 2 0.78 100.00 % 0 0 0
openai-ruby/lib/openai/internal/cursor_page.rb 36.67 % 86 30 11 19 0.37 0.00 % 14 0 14
openai-ruby/lib/openai/internal/page.rb 42.31 % 80 26 11 15 0.42 0.00 % 8 0 8
openai-ruby/lib/openai/internal/stream.rb 25.00 % 61 20 5 15 0.25 0.00 % 11 0 11
openai-ruby/lib/openai/internal/transport/base_client.rb 58.04 % 566 143 83 60 1.20 24.07 % 54 13 41
openai-ruby/lib/openai/internal/transport/pooled_net_requester.rb 87.50 % 209 80 70 10 2.06 32.26 % 31 10 21
openai-ruby/lib/openai/internal/type/array_of.rb 48.78 % 167 41 20 21 5.56 0.00 % 8 0 8
openai-ruby/lib/openai/internal/type/base_model.rb 38.37 % 529 172 66 106 197.44 17.74 % 62 11 51
openai-ruby/lib/openai/internal/type/base_page.rb 71.43 % 55 14 10 4 0.71 100.00 % 0 0 0
openai-ruby/lib/openai/internal/type/base_stream.rb 51.85 % 92 27 14 13 0.52 0.00 % 2 0 2
openai-ruby/lib/openai/internal/type/boolean.rb 80.00 % 77 15 12 3 0.80 0.00 % 2 0 2
openai-ruby/lib/openai/internal/type/converter.rb 43.48 % 300 92 40 52 151.91 25.49 % 51 13 38
openai-ruby/lib/openai/internal/type/enum.rb 37.14 % 156 35 13 22 0.37 0.00 % 17 0 17
openai-ruby/lib/openai/internal/type/file_input.rb 41.38 % 108 29 12 17 0.41 0.00 % 8 0 8
openai-ruby/lib/openai/internal/type/hash_of.rb 39.22 % 187 51 20 31 4.12 0.00 % 16 0 16
openai-ruby/lib/openai/internal/type/request_parameters.rb 93.33 % 42 15 14 1 15.80 50.00 % 6 3 3
openai-ruby/lib/openai/internal/type/union.rb 43.59 % 260 78 34 44 39.29 18.42 % 38 7 31
openai-ruby/lib/openai/internal/type/unknown.rb 80.00 % 81 15 12 3 0.80 100.00 % 0 0 0
openai-ruby/lib/openai/internal/util.rb 42.81 % 914 313 134 179 40.77 22.56 % 164 37 127
openai-ruby/lib/openai/models.rb 95.12 % 251 123 117 6 53.06 66.67 % 9 6 3
openai-ruby/lib/openai/models/all_models.rb 100.00 % 36 19 19 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/speech_create_params.rb 98.00 % 171 50 49 1 0.98 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/speech_model.rb 100.00 % 18 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription.rb 96.55 % 178 29 28 1 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription_create_params.rb 92.11 % 222 38 35 3 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription_create_response.rb 100.00 % 26 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription_include.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription_segment.rb 100.00 % 96 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription_stream_event.rb 100.00 % 26 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription_text_delta_event.rb 91.67 % 75 12 11 1 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription_text_done_event.rb 91.30 % 155 23 21 2 0.91 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription_verbose.rb 100.00 % 83 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/transcription_word.rb 100.00 % 34 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/translation.rb 100.00 % 17 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/translation_create_params.rb 100.00 % 98 22 22 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/translation_create_response.rb 100.00 % 19 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio/translation_verbose.rb 100.00 % 42 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio_model.rb 100.00 % 16 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/audio_response_format.rb 100.00 % 21 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/auto_file_chunking_strategy_param.rb 100.00 % 19 4 4 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/batch.rb 100.00 % 213 36 36 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/batch_cancel_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/batch_create_params.rb 100.00 % 93 18 18 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/batch_error.rb 100.00 % 40 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/batch_list_params.rb 100.00 % 37 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/batch_request_counts.rb 100.00 % 34 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/batch_retrieve_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant.rb 100.00 % 218 24 24 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_create_params.rb 88.46 % 372 52 46 6 0.88 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_delete_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_deleted.rb 100.00 % 30 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_list_params.rb 100.00 % 71 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_response_format_option.rb 100.00 % 50 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_retrieve_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_stream_event.rb 94.50 % 754 109 103 6 0.94 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_tool.rb 100.00 % 22 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_tool_choice.rb 100.00 % 42 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_tool_choice_function.rb 100.00 % 18 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_tool_choice_option.rb 100.00 % 42 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/assistant_update_params.rb 98.04 % 345 102 100 2 0.98 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/code_interpreter_tool.rb 100.00 % 18 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/file_search_tool.rb 100.00 % 110 16 16 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/function_tool.rb 100.00 % 25 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/message_stream_event.rb 96.30 % 171 27 26 1 0.96 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/run_step_stream_event.rb 97.14 % 225 35 34 1 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/run_stream_event.rb 100.00 % 299 46 46 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/thread.rb 100.00 % 122 16 16 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/thread_create_and_run_params.rb 85.98 % 722 107 92 15 0.86 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/thread_create_params.rb 87.88 % 391 66 58 8 0.88 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/thread_delete_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/thread_deleted.rb 100.00 % 30 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/thread_retrieve_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/thread_stream_event.rb 100.00 % 41 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/thread_update_params.rb 100.00 % 101 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/annotation.rb 100.00 % 27 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/annotation_delta.rb 100.00 % 27 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/file_citation_annotation.rb 100.00 % 65 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/file_citation_delta_annotation.rb 100.00 % 81 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/file_path_annotation.rb 100.00 % 64 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/file_path_delta_annotation.rb 100.00 % 72 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/image_file.rb 100.00 % 49 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/image_file_content_block.rb 100.00 % 30 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/image_file_delta.rb 100.00 % 49 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/image_file_delta_block.rb 100.00 % 38 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/image_url.rb 100.00 % 48 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/image_url_content_block.rb 100.00 % 29 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/image_url_delta.rb 100.00 % 48 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/image_url_delta_block.rb 100.00 % 37 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message.rb 92.00 % 251 50 46 4 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_content.rb 100.00 % 32 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_content_delta.rb 100.00 % 32 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_content_part_param.rb 100.00 % 29 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_create_params.rb 90.91 % 150 33 30 3 0.91 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_delete_params.rb 100.00 % 24 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_deleted.rb 100.00 % 32 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_delta.rb 91.67 % 44 12 11 1 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_delta_event.rb 100.00 % 39 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_list_params.rb 100.00 % 81 16 16 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_retrieve_params.rb 100.00 % 24 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/message_update_params.rb 100.00 % 41 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/refusal_content_block.rb 100.00 % 29 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/refusal_delta_block.rb 100.00 % 37 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/required_action_function_tool_call.rb 100.00 % 68 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/run.rb 96.88 % 475 64 62 2 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/run_cancel_params.rb 100.00 % 24 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/run_create_params.rb 88.06 % 443 67 59 8 0.88 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/run_list_params.rb 100.00 % 73 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/run_retrieve_params.rb 100.00 % 24 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/run_status.rb 100.00 % 29 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rb 92.31 % 62 13 12 1 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/run_update_params.rb 100.00 % 41 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/code_interpreter_logs.rb 100.00 % 40 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/code_interpreter_output_image.rb 100.00 % 54 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rb 83.33 % 158 30 25 5 0.83 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rb 90.00 % 100 20 18 2 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/file_search_tool_call.rb 85.71 % 193 35 30 5 0.86 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/file_search_tool_call_delta.rb 100.00 % 50 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/function_tool_call.rb 100.00 % 78 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/function_tool_call_delta.rb 100.00 % 86 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/message_creation_step_details.rb 90.91 % 44 11 10 1 0.91 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/run_step.rb 100.00 % 278 50 50 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/run_step_delta.rb 100.00 % 44 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/run_step_delta_event.rb 100.00 % 43 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/run_step_delta_message_delta.rb 91.67 % 48 12 11 1 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/run_step_include.rb 100.00 % 23 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/step_list_params.rb 94.74 % 97 19 18 1 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/step_retrieve_params.rb 91.67 % 52 12 11 1 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/tool_call.rb 100.00 % 28 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/tool_call_delta.rb 100.00 % 28 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/tool_call_delta_object.rb 88.89 % 38 9 8 1 0.89 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/runs/tool_calls_step_details.rb 88.89 % 40 9 8 1 0.89 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/text.rb 87.50 % 30 8 7 1 0.88 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/text_content_block.rb 100.00 % 29 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/text_content_block_param.rb 100.00 % 30 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/text_delta.rb 87.50 % 28 8 7 1 0.88 100.00 % 0 0 0
openai-ruby/lib/openai/models/beta/threads/text_delta_block.rb 100.00 % 37 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion.rb 94.59 % 227 37 35 2 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_assistant_message_param.rb 87.10 % 178 31 27 4 0.87 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_audio.rb 100.00 % 53 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_audio_param.rb 97.22 % 101 36 35 1 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_chunk.rb 93.94 % 410 66 62 4 0.94 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_content_part.rb 100.00 % 85 18 18 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_content_part_image.rb 100.00 % 69 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_content_part_input_audio.rb 93.33 % 68 15 14 1 0.93 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_content_part_refusal.rb 100.00 % 28 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_content_part_text.rb 100.00 % 31 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_deleted.rb 100.00 % 37 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_developer_message_param.rb 100.00 % 64 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_function_call_option.rb 100.00 % 23 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_function_message_param.rb 100.00 % 37 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_message.rb 92.31 % 179 26 24 2 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_message_param.rb 100.00 % 42 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_message_tool_call.rb 100.00 % 71 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_modality.rb 100.00 % 19 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_named_tool_choice.rb 100.00 % 42 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_prediction_content.rb 100.00 % 60 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_reasoning_effort.rb 100.00 % 11 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_role.rb 100.00 % 24 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_store_message.rb 91.67 % 53 12 11 1 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_stream_options.rb 100.00 % 31 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_system_message_param.rb 100.00 % 64 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_token_logprob.rb 92.86 % 90 14 13 1 0.93 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_tool.rb 100.00 % 27 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_tool_choice_option.rb 100.00 % 45 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_tool_message_param.rb 100.00 % 56 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/chat_completion_user_message_param.rb 100.00 % 63 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/completion_create_params.rb 92.93 % 744 99 92 7 0.93 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/completion_delete_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/completion_list_params.rb 100.00 % 74 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/completion_retrieve_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/completion_update_params.rb 100.00 % 32 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat/completions/message_list_params.rb 100.00 % 58 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/chat_model.rb 100.00 % 68 59 59 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/comparison_filter.rb 100.00 % 87 19 19 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/completion.rb 100.00 % 76 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/completion_choice.rb 100.00 % 89 17 17 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/completion_create_params.rb 97.87 % 306 47 46 1 0.98 100.00 % 0 0 0
openai-ruby/lib/openai/models/completion_usage.rb 100.00 % 117 16 16 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/compound_filter.rb 100.00 % 57 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/container_create_params.rb 100.00 % 75 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/container_create_response.rb 100.00 % 98 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/container_delete_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/container_list_params.rb 100.00 % 58 12 12 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/container_list_response.rb 100.00 % 98 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/container_retrieve_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/container_retrieve_response.rb 100.00 % 98 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/containers/file_create_params.rb 100.00 % 35 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/containers/file_create_response.rb 100.00 % 67 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/containers/file_delete_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/containers/file_list_params.rb 100.00 % 60 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/containers/file_list_response.rb 100.00 % 67 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/containers/file_retrieve_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/containers/file_retrieve_response.rb 100.00 % 67 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/containers/files/content_retrieve_params.rb 100.00 % 24 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/create_embedding_response.rb 100.00 % 63 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/embedding.rb 100.00 % 39 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/embedding_create_params.rb 100.00 % 139 27 27 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/embedding_model.rb 100.00 % 16 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/error_object.rb 100.00 % 33 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_create_params.rb 92.05 % 496 88 81 7 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_create_response.rb 97.06 % 214 34 33 1 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_custom_data_source_config.rb 100.00 % 35 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_delete_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_delete_response.rb 100.00 % 28 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_list_params.rb 100.00 % 75 17 17 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_list_response.rb 97.06 % 214 34 33 1 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_retrieve_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_retrieve_response.rb 97.06 % 214 34 33 1 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_stored_completions_data_source_config.rb 100.00 % 44 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_update_params.rb 100.00 % 38 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/eval_update_response.rb 97.06 % 214 34 33 1 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/create_eval_completions_run_data_source.rb 88.24 % 576 102 90 12 0.88 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/create_eval_jsonl_run_data_source.rb 95.24 % 102 21 20 1 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/eval_api_error.rb 100.00 % 30 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_cancel_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_cancel_response.rb 89.51 % 877 143 128 15 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_create_params.rb 84.00 % 725 125 105 20 0.84 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_create_response.rb 89.51 % 877 143 128 15 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_delete_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_delete_response.rb 100.00 % 30 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_list_params.rb 100.00 % 80 21 21 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_list_response.rb 90.14 % 876 142 128 14 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_retrieve_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/run_retrieve_response.rb 89.51 % 881 143 128 15 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/runs/output_item_list_params.rb 100.00 % 86 20 20 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/runs/output_item_list_response.rb 94.87 % 265 39 37 2 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/runs/output_item_retrieve_params.rb 100.00 % 30 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/evals/runs/output_item_retrieve_response.rb 94.87 % 266 39 37 2 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_chunking_strategy.rb 100.00 % 20 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_chunking_strategy_param.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_content.rb 100.00 % 7 3 3 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_content_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_create_params.rb 100.00 % 36 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_delete_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_deleted.rb 100.00 % 28 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_list_params.rb 100.00 % 66 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_object.rb 100.00 % 132 27 27 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_purpose.rb 100.00 % 23 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/file_retrieve_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/alpha/grader_run_params.rb 100.00 % 76 18 18 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/alpha/grader_run_response.rb 100.00 % 175 32 32 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/alpha/grader_validate_params.rb 100.00 % 49 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/alpha/grader_validate_response.rb 100.00 % 46 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_create_params.rb 100.00 % 26 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_create_response.rb 100.00 % 48 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_delete_params.rb 100.00 % 24 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_delete_response.rb 100.00 % 37 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_retrieve_params.rb 100.00 % 61 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_retrieve_response.rb 93.75 % 83 16 15 1 0.94 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/dpo_hyperparameters.rb 96.00 % 112 25 24 1 0.96 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/dpo_method.rb 100.00 % 20 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job.rb 95.38 % 382 65 62 3 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job_event.rb 100.00 % 98 21 21 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job_integration.rb 100.00 % 11 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rb 100.00 % 57 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rb 100.00 % 35 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/job_cancel_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/job_create_params.rb 95.31 % 379 64 61 3 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/job_list_events_params.rb 100.00 % 32 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/job_list_params.rb 100.00 % 44 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/job_pause_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/job_resume_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/job_retrieve_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rb 100.00 % 34 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rb 100.00 % 121 20 20 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/reinforcement_hyperparameters.rb 93.18 % 181 44 41 3 0.93 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/reinforcement_method.rb 100.00 % 53 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/supervised_hyperparameters.rb 95.00 % 88 20 19 1 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/fine_tuning/supervised_method.rb 100.00 % 20 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/function_definition.rb 100.00 % 55 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/function_parameters.rb 100.00 % 8 3 3 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/graders/label_model_grader.rb 100.00 % 214 39 39 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/graders/multi_grader.rb 100.00 % 78 16 16 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/graders/python_grader.rb 100.00 % 46 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/graders/score_model_grader.rb 100.00 % 214 39 39 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/graders/string_check_grader.rb 100.00 % 70 16 16 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/graders/text_similarity_grader.rb 100.00 % 80 22 22 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image.rb 100.00 % 41 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_create_variation_params.rb 100.00 % 112 24 24 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_edit_completed_event.rb 100.00 % 198 41 41 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_edit_params.rb 100.00 % 297 61 61 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_edit_partial_image_event.rb 100.00 % 135 33 33 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_edit_stream_event.rb 100.00 % 21 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_gen_completed_event.rb 100.00 % 198 41 41 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_gen_partial_image_event.rb 100.00 % 135 33 33 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_gen_stream_event.rb 100.00 % 21 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_generate_params.rb 100.00 % 287 62 62 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/image_model.rb 100.00 % 16 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/images_response.rb 100.00 % 189 37 37 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/metadata.rb 100.00 % 8 3 3 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/model.rb 100.00 % 43 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/model_delete_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/model_deleted.rb 100.00 % 28 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/model_list_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/model_retrieve_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/moderation.rb 87.85 % 563 107 94 13 0.88 100.00 % 0 0 0
openai-ruby/lib/openai/models/moderation_create_params.rb 100.00 % 80 18 18 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/moderation_create_response.rb 100.00 % 35 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/moderation_image_url_input.rb 100.00 % 40 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/moderation_model.rb 100.00 % 17 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/moderation_multi_modal_input.rb 100.00 % 21 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/moderation_text_input.rb 100.00 % 26 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/other_file_chunking_strategy_object.rb 100.00 % 20 4 4 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/reasoning.rb 100.00 % 89 16 16 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/reasoning_effort.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/response_format_json_object.rb 100.00 % 20 4 4 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/response_format_json_schema.rb 90.91 % 85 11 10 1 0.91 100.00 % 0 0 0
openai-ruby/lib/openai/models/response_format_text.rb 100.00 % 18 4 4 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/computer_tool.rb 100.00 % 61 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/easy_input_message.rb 100.00 % 91 20 20 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/file_search_tool.rb 100.00 % 114 20 20 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/function_tool.rb 100.00 % 63 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/input_item_list_params.rb 100.00 % 78 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response.rb 89.86 % 498 69 62 7 0.90 0.00 % 4 0 4
openai-ruby/lib/openai/models/responses/response_audio_delta_event.rb 100.00 % 39 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_audio_done_event.rb 100.00 % 31 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_audio_transcript_delta_event.rb 100.00 % 39 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_audio_transcript_done_event.rb 100.00 % 31 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_cancel_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_code_interpreter_call_code_delta_event.rb 100.00 % 57 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_code_interpreter_call_code_done_event.rb 100.00 % 52 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_code_interpreter_call_completed_event.rb 100.00 % 49 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_code_interpreter_call_in_progress_event.rb 100.00 % 49 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_code_interpreter_call_interpreting_event.rb 100.00 % 49 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_code_interpreter_tool_call.rb 96.55 % 144 29 28 1 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_completed_event.rb 100.00 % 39 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_computer_tool_call.rb 97.44 % 493 78 76 2 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_computer_tool_call_output_item.rb 95.00 % 111 20 19 1 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_computer_tool_call_output_screenshot.rb 100.00 % 41 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_content.rb 100.00 % 30 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_content_part_added_event.rb 100.00 % 81 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_content_part_done_event.rb 100.00 % 81 15 15 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_create_params.rb 98.11 % 431 53 52 1 1.11 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_created_event.rb 100.00 % 39 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_delete_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_error.rb 100.00 % 60 26 26 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_error_event.rb 100.00 % 55 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_failed_event.rb 100.00 % 39 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_file_search_call_completed_event.rb 100.00 % 48 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_file_search_call_in_progress_event.rb 100.00 % 48 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_file_search_call_searching_event.rb 100.00 % 48 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_file_search_tool_call.rb 93.10 % 147 29 27 2 0.93 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_format_text_config.rb 100.00 % 48 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_format_text_json_schema_config.rb 90.00 % 70 10 9 1 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_function_call_arguments_delta_event.rb 100.00 % 56 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_function_call_arguments_done_event.rb 100.00 % 51 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_function_tool_call.rb 100.00 % 87 16 16 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_function_tool_call_item.rb 100.00 % 25 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_function_tool_call_output_item.rb 100.00 % 70 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_function_web_search.rb 100.00 % 170 30 30 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_image_gen_call_completed_event.rb 100.00 % 45 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_image_gen_call_generating_event.rb 100.00 % 45 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_image_gen_call_in_progress_event.rb 100.00 % 44 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_image_gen_call_partial_image_event.rb 100.00 % 65 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_in_progress_event.rb 100.00 % 39 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_includable.rb 100.00 % 37 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_incomplete_event.rb 100.00 % 39 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_input.rb 100.00 % 10 4 4 0 1.50 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_input_audio.rb 100.00 % 52 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_input_content.rb 100.00 % 26 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_input_file.rb 100.00 % 55 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_input_image.rb 100.00 % 65 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_input_item.rb 96.05 % 876 152 146 6 1.21 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_input_message_content_list.rb 100.00 % 11 4 4 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_input_message_item.rb 95.65 % 99 23 22 1 0.96 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_input_text.rb 100.00 % 28 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_item.rb 97.87 % 549 94 92 2 0.98 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_item_list.rb 100.00 % 54 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_mcp_call_arguments_delta_event.rb 100.00 % 58 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_mcp_call_arguments_done_event.rb 100.00 % 55 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_mcp_call_completed_event.rb 100.00 % 44 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_mcp_call_failed_event.rb 100.00 % 44 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_mcp_call_in_progress_event.rb 100.00 % 44 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_mcp_list_tools_completed_event.rb 100.00 % 44 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_mcp_list_tools_failed_event.rb 100.00 % 44 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_mcp_list_tools_in_progress_event.rb 100.00 % 45 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_output_audio.rb 100.00 % 39 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_output_item.rb 98.63 % 442 73 72 1 0.99 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_output_item_added_event.rb 100.00 % 47 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_output_item_done_event.rb 100.00 % 47 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_output_message.rb 95.00 % 90 20 19 1 0.95 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_output_refusal.rb 100.00 % 28 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_output_text.rb 92.16 % 303 51 47 4 0.92 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_output_text_annotation_added_event.rb 100.00 % 68 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_prompt.rb 92.86 % 63 14 13 1 0.93 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_queued_event.rb 100.00 % 36 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_reasoning_item.rb 94.44 % 98 18 17 1 0.94 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_reasoning_summary_delta_event.rb 100.00 % 65 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_reasoning_summary_done_event.rb 100.00 % 60 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_reasoning_summary_part_added_event.rb 100.00 % 86 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_reasoning_summary_part_done_event.rb 100.00 % 86 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_reasoning_summary_text_delta_event.rb 100.00 % 64 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_reasoning_summary_text_done_event.rb 100.00 % 64 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_refusal_delta_event.rb 100.00 % 63 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_refusal_done_event.rb 100.00 % 63 10 10 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_retrieve_params.rb 100.00 % 38 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_status.rb 100.00 % 23 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_stream_event.rb 66.28 % 211 86 57 29 0.66 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_text_config.rb 100.00 % 39 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_text_delta_event.rb 90.00 % 128 20 18 2 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_text_done_event.rb 90.00 % 128 20 18 2 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_usage.rb 100.00 % 85 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_web_search_call_completed_event.rb 100.00 % 48 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_web_search_call_in_progress_event.rb 100.00 % 48 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/response_web_search_call_searching_event.rb 100.00 % 48 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/tool.rb 97.22 % 549 108 105 3 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/tool_choice_function.rb 100.00 % 28 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/tool_choice_mcp.rb 100.00 % 40 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/tool_choice_options.rb 100.00 % 26 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/tool_choice_types.rb 100.00 % 59 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses/web_search_tool.rb 100.00 % 123 22 22 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/responses_model.rb 100.00 % 36 19 19 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/static_file_chunking_strategy.rb 100.00 % 30 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/static_file_chunking_strategy_object.rb 100.00 % 23 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/static_file_chunking_strategy_object_param.rb 100.00 % 25 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/upload.rb 100.00 % 103 18 18 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/upload_cancel_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/upload_complete_params.rb 100.00 % 34 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/upload_create_params.rb 100.00 % 55 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/uploads/part_create_params.rb 100.00 % 27 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/uploads/upload_part.rb 100.00 % 47 9 9 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_store.rb 100.00 % 195 28 28 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_store_create_params.rb 100.00 % 90 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_store_delete_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_store_deleted.rb 100.00 % 28 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_store_list_params.rb 100.00 % 69 13 13 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_store_retrieve_params.rb 100.00 % 14 5 5 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_store_search_params.rb 100.00 % 116 26 26 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_store_search_response.rb 90.48 % 103 21 19 2 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_store_update_params.rb 100.00 % 71 11 11 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_batch_cancel_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_batch_create_params.rb 93.33 % 67 15 14 1 0.93 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_batch_list_files_params.rb 100.00 % 99 22 22 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_batch_retrieve_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_content_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_content_response.rb 100.00 % 27 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_create_params.rb 93.33 % 67 15 14 1 0.93 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_delete_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_list_params.rb 100.00 % 92 21 21 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_retrieve_params.rb 100.00 % 22 7 7 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/file_update_params.rb 92.86 % 55 14 13 1 0.93 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/vector_store_file.rb 97.06 % 172 34 33 1 0.97 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/vector_store_file_batch.rb 100.00 % 130 23 23 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/vector_stores/vector_store_file_deleted.rb 100.00 % 32 8 8 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/batch_cancelled_webhook_event.rb 100.00 % 84 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/batch_completed_webhook_event.rb 100.00 % 84 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/batch_expired_webhook_event.rb 100.00 % 84 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/batch_failed_webhook_event.rb 100.00 % 84 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/eval_run_canceled_webhook_event.rb 100.00 % 84 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/eval_run_failed_webhook_event.rb 100.00 % 84 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/eval_run_succeeded_webhook_event.rb 100.00 % 84 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/fine_tuning_job_cancelled_webhook_event.rb 100.00 % 85 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/fine_tuning_job_failed_webhook_event.rb 100.00 % 85 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/fine_tuning_job_succeeded_webhook_event.rb 100.00 % 85 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/response_cancelled_webhook_event.rb 100.00 % 85 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/response_completed_webhook_event.rb 100.00 % 85 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/response_failed_webhook_event.rb 100.00 % 84 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/response_incomplete_webhook_event.rb 100.00 % 85 14 14 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/unwrap_webhook_event.rb 100.00 % 59 20 20 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/models/webhooks/webhook_unwrap_params.rb 100.00 % 16 6 6 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/request_options.rb 75.00 % 77 16 12 4 0.88 25.00 % 4 1 3
openai-ruby/lib/openai/resources/audio.rb 100.00 % 26 11 11 0 1.36 100.00 % 0 0 0
openai-ruby/lib/openai/resources/audio/speech.rb 77.78 % 54 9 7 2 0.89 100.00 % 0 0 0
openai-ruby/lib/openai/resources/audio/transcriptions.rb 42.11 % 116 19 8 11 0.47 0.00 % 4 0 4
openai-ruby/lib/openai/resources/audio/translations.rb 77.78 % 50 9 7 2 0.89 100.00 % 0 0 0
openai-ruby/lib/openai/resources/batches.rb 60.00 % 109 15 9 6 0.67 100.00 % 0 0 0
openai-ruby/lib/openai/resources/beta.rb 100.00 % 22 9 9 0 1.33 100.00 % 0 0 0
openai-ruby/lib/openai/resources/beta/assistants.rb 57.89 % 180 19 11 8 0.63 100.00 % 0 0 0
openai-ruby/lib/openai/resources/beta/threads.rb 48.57 % 261 35 17 18 0.57 0.00 % 4 0 4
openai-ruby/lib/openai/resources/beta/threads/messages.rb 42.86 % 188 28 12 16 0.46 100.00 % 0 0 0
openai-ruby/lib/openai/resources/beta/threads/runs.rb 28.81 % 391 59 17 42 0.32 0.00 % 8 0 8
openai-ruby/lib/openai/resources/beta/threads/runs/steps.rb 50.00 % 106 20 10 10 0.55 100.00 % 0 0 0
openai-ruby/lib/openai/resources/chat.rb 100.00 % 18 7 7 0 1.29 100.00 % 0 0 0
openai-ruby/lib/openai/resources/chat/completions.rb 22.06 % 438 68 15 53 0.25 0.00 % 22 0 22
openai-ruby/lib/openai/resources/chat/completions/messages.rb 80.00 % 51 10 8 2 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/resources/completions.rb 38.89 % 143 18 7 11 0.44 0.00 % 4 0 4
openai-ruby/lib/openai/resources/containers.rb 64.71 % 113 17 11 6 0.76 100.00 % 0 0 0
openai-ruby/lib/openai/resources/containers/files.rb 50.00 % 135 24 12 12 0.58 100.00 % 0 0 0
openai-ruby/lib/openai/resources/containers/files/content.rb 66.67 % 44 12 8 4 0.75 100.00 % 0 0 0
openai-ruby/lib/openai/resources/embeddings.rb 75.00 % 47 8 6 2 0.88 100.00 % 0 0 0
openai-ruby/lib/openai/resources/evals.rb 60.00 % 155 20 12 8 0.70 100.00 % 0 0 0
openai-ruby/lib/openai/resources/evals/runs.rb 44.83 % 168 29 13 16 0.52 100.00 % 0 0 0
openai-ruby/lib/openai/resources/evals/runs/output_items.rb 47.37 % 91 19 9 10 0.53 100.00 % 0 0 0
openai-ruby/lib/openai/resources/files.rb 58.82 % 155 17 10 7 0.65 100.00 % 0 0 0
openai-ruby/lib/openai/resources/fine_tuning.rb 100.00 % 30 13 13 0 1.38 100.00 % 0 0 0
openai-ruby/lib/openai/resources/fine_tuning/alpha.rb 100.00 % 20 8 8 0 1.25 100.00 % 0 0 0
openai-ruby/lib/openai/resources/fine_tuning/alpha/graders.rb 69.23 % 69 13 9 4 0.77 100.00 % 0 0 0
openai-ruby/lib/openai/resources/fine_tuning/checkpoints.rb 100.00 % 20 8 8 0 1.25 100.00 % 0 0 0
openai-ruby/lib/openai/resources/fine_tuning/checkpoints/permissions.rb 55.56 % 125 18 10 8 0.61 100.00 % 0 0 0
openai-ruby/lib/openai/resources/fine_tuning/jobs.rb 60.00 % 221 25 15 10 0.68 100.00 % 0 0 0
openai-ruby/lib/openai/resources/fine_tuning/jobs/checkpoints.rb 80.00 % 48 10 8 2 0.90 100.00 % 0 0 0
openai-ruby/lib/openai/resources/fine_tuning/methods.rb 100.00 % 16 6 6 0 1.17 100.00 % 0 0 0
openai-ruby/lib/openai/resources/graders.rb 100.00 % 18 7 7 0 1.29 100.00 % 0 0 0
openai-ruby/lib/openai/resources/graders/grader_models.rb 100.00 % 16 6 6 0 1.17 100.00 % 0 0 0
openai-ruby/lib/openai/resources/images.rb 29.41 % 285 34 10 24 0.32 0.00 % 8 0 8
openai-ruby/lib/openai/resources/models.rb 72.73 % 76 11 8 3 0.82 100.00 % 0 0 0
openai-ruby/lib/openai/resources/moderations.rb 75.00 % 42 8 6 2 0.88 100.00 % 0 0 0
openai-ruby/lib/openai/resources/responses.rb 25.00 % 581 108 27 81 0.35 5.00 % 40 2 38
openai-ruby/lib/openai/resources/responses/input_items.rb 77.78 % 52 9 7 2 0.89 100.00 % 0 0 0
openai-ruby/lib/openai/resources/uploads.rb 66.67 % 125 15 10 5 0.80 100.00 % 0 0 0
openai-ruby/lib/openai/resources/uploads/parts.rb 77.78 % 54 9 7 2 0.89 100.00 % 0 0 0
openai-ruby/lib/openai/resources/vector_stores.rb 60.00 % 195 25 15 10 0.72 100.00 % 0 0 0
openai-ruby/lib/openai/resources/vector_stores/file_batches.rb 41.67 % 144 24 10 14 0.46 100.00 % 0 0 0
openai-ruby/lib/openai/resources/vector_stores/files.rb 37.50 % 203 32 12 20 0.41 100.00 % 0 0 0
openai-ruby/lib/openai/resources/webhooks.rb 21.95 % 124 41 9 32 0.24 0.00 % 18 0 18
openai-ruby/lib/openai/streaming.rb 100.00 % 5 2 2 0 1.00 100.00 % 0 0 0
openai-ruby/lib/openai/structured_output.rb 100.00 % 10 7 7 0 1.00 100.00 % 0 0 0

lib/ai/chat.rb

44.44% lines covered

16.67% branches covered

126 relevant lines. 56 lines covered and 70 lines missed.
60 total branches, 10 branches covered and 50 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "base64"
  3. 1 require "mime-types"
  4. 1 require "openai"
  5. 1 require_relative "response"
  6. 1 module AI
  7. # Main namespace.
  8. 1 class Chat
  9. 1 attr_accessor :messages, :model, :web_search, :previous_response_id
  10. 1 attr_reader :reasoning_effort, :client, :schema
  11. 1 VALID_REASONING_EFFORTS = [:low, :medium, :high].freeze
  12. 1 def initialize(api_key: nil, api_key_env_var: "OPENAI_API_KEY")
  13. 2 @api_key = api_key || ENV.fetch(api_key_env_var)
  14. 2 @messages = []
  15. 2 @reasoning_effort = nil
  16. 2 @model = "gpt-4.1-nano"
  17. 2 @client = OpenAI::Client.new(api_key: @api_key)
  18. 2 @previous_response_id = nil
  19. end
  20. 1 def add(content, role: "user", response: nil, image: nil, images: nil, file: nil, files: nil)
  21. 4 then: 4 if image.nil? && images.nil? && file.nil? && files.nil?
  22. 4 messages.push(
  23. {
  24. role: role,
  25. content: content,
  26. response: response
  27. }.compact
  28. )
  29. else: 0 else
  30. text_and_files_array = [
  31. {
  32. type: "input_text",
  33. text: content
  34. }
  35. ]
  36. then: 0 if images && !images.empty?
  37. images_array = images.map do |image|
  38. {
  39. type: "input_image",
  40. image_url: process_file(image)
  41. }
  42. end
  43. else: 0 text_and_files_array += images_array
  44. then: 0 elsif image
  45. text_and_files_array.push(
  46. {
  47. type: "input_image",
  48. image_url: process_file(image)
  49. }
  50. else: 0 )
  51. then: 0 elsif files && !files.empty?
  52. files_array = files.map do |file|
  53. {
  54. type: "input_file",
  55. filename: "test",
  56. file_data: process_file(file)
  57. }
  58. end
  59. text_and_files_array += files_array
  60. else: 0 else
  61. text_and_files_array.push(
  62. {
  63. type: "input_file",
  64. filename: "test",
  65. file_data: process_file(file)
  66. }
  67. )
  68. end
  69. messages.push(
  70. {
  71. role: role,
  72. content: text_and_files_array
  73. }
  74. )
  75. end
  76. end
  77. 1 def system(message)
  78. 2 add(message, role: "system")
  79. end
  80. 1 def user(message, image: nil, images: nil, file: nil, files: nil)
  81. 2 add(message, role: "user", image: image, images: images, file: file, files: files)
  82. end
  83. 1 def assistant(message, response: nil)
  84. add(message, role: "assistant", response: response)
  85. end
  86. 1 def generate!
  87. 2 response = create_response
  88. chat_response = Response.new(response)
  89. then: 0 message = if web_search
  90. else: 0 response.output.last.content.first.text
  91. elsif schema
  92. then: 0 # filtering out refusals...
  93. json_response = extract_text_from_response(response)
  94. JSON.parse(json_response, symbolize_names: true)
  95. else: 0 else
  96. response.output.last.content.first.text
  97. end
  98. assistant(message, response: chat_response)
  99. # Update previous_response_id for next request
  100. self.previous_response_id = response.id
  101. message
  102. end
  103. 1 def reasoning_effort=(value)
  104. then: 0 if value.nil?
  105. @reasoning_effort = nil
  106. else
  107. else: 0 # Convert string to symbol if needed
  108. then: 0 else: 0 symbol_value = value.is_a?(String) ? value.to_sym : value
  109. then: 0 if VALID_REASONING_EFFORTS.include?(symbol_value)
  110. @reasoning_effort = symbol_value
  111. else: 0 else
  112. valid_values = VALID_REASONING_EFFORTS.map { |v| ":#{v} or \"#{v}\"" }.join(", ")
  113. raise ArgumentError, "Invalid reasoning_effort value: '#{value}'. Must be one of: #{valid_values}"
  114. end
  115. end
  116. end
  117. 1 def schema=(value)
  118. 2 then: 1 if value.is_a?(String)
  119. 1 @schema = JSON.parse(value, symbolize_names: true)
  120. 1 else: 0 then: 1 unless @schema.key?(:format) || @schema.key?("format")
  121. 1 @schema = {format: @schema}
  122. else: 1 end
  123. 1 then: 1 elsif value.is_a?(Hash)
  124. 1 then: 0 @schema = if value.key?(:format) || value.key?("format")
  125. value
  126. else: 1 else
  127. 1 {format: value}
  128. end
  129. else: 0 else
  130. raise ArgumentError, "Invalid schema value: '#{value}'. Must be a String containing JSON or a Hash."
  131. end
  132. end
  133. 1 def last
  134. messages.last
  135. end
  136. 1 def inspect
  137. "#<#{self.class.name} @messages=#{messages.inspect} @model=#{@model.inspect} @schema=#{@schema.inspect} @reasoning_effort=#{@reasoning_effort.inspect}>"
  138. end
  139. 1 private
  140. # Custom exception class for input classification errors.
  141. 1 class InputClassificationError < StandardError; end
  142. 1 def create_response
  143. parameters = {
  144. 2 model: model,
  145. tools: tools,
  146. text: schema,
  147. reasoning: {
  148. effort: reasoning_effort
  149. }.compact,
  150. previous_response_id: previous_response_id
  151. }.compact
  152. # Determine which messages to send based on whether we're using previous_response_id
  153. 2 if previous_response_id
  154. then: 0 # Find the index of the message with the matching response_id
  155. then: 0 else: 0 previous_response_index = messages.find_index { |m| m[:response]&.id == previous_response_id }
  156. if previous_response_index
  157. then: 0 # Only send messages after the previous response
  158. new_messages = messages[(previous_response_index + 1)..]
  159. else: 0 then: 0 parameters[:input] = strip_responses(new_messages) unless new_messages.empty?
  160. else
  161. else: 0 # If we can't find the previous response, send all messages
  162. parameters[:input] = strip_responses(messages)
  163. end
  164. else
  165. else: 2 # Send full message history when not using previous_response_id
  166. 2 parameters[:input] = strip_responses(messages)
  167. end
  168. 12 parameters = parameters.delete_if { |k, v| v.empty? }
  169. 2 client.responses.create(**parameters)
  170. end
  171. 1 def classify_obj(obj)
  172. if obj.is_a?(String)
  173. # Attempt to parse as a URL.
  174. then: 0 begin
  175. uri = URI.parse(obj)
  176. then: 0 else: 0 if uri.is_a?(URI::HTTP) || uri.is_a?(URI::HTTPS)
  177. return :url
  178. end
  179. rescue URI::InvalidURIError
  180. # Not a valid URL; continue to check if it's a file path.
  181. end
  182. # Check if the string represents a local file path (must exist on disk).
  183. then: 0 if File.exist?(obj)
  184. :file_path
  185. else: 0 else
  186. raise InputClassificationError,
  187. "String provided is neither a valid URL (must start with http:// or https://) nor an existing file path on disk. Received value: #{obj.inspect}"
  188. else: 0 end
  189. elsif obj.respond_to?(:read)
  190. then: 0 # For non-String objects, check if it behaves like a file.
  191. :file_like
  192. else: 0 else
  193. raise InputClassificationError,
  194. "Object provided is neither a String nor file-like (missing :read method). Received value: #{obj.inspect}"
  195. end
  196. end
  197. 1 def process_file(obj)
  198. else: 0 case classify_obj(obj)
  199. when: 0 when :url
  200. obj
  201. when: 0 when :file_path
  202. file_path = obj
  203. mime_type = MIME::Types.type_for(file_path).first.to_s
  204. image_data = File.binread(file_path)
  205. base64_string = Base64.strict_encode64(image_data)
  206. "data:#{mime_type};base64,#{base64_string}"
  207. when: 0 when :file_like
  208. then: 0 filename = if obj.respond_to?(:path)
  209. else: 0 obj.path
  210. then: 0 elsif obj.respond_to?(:original_filename)
  211. obj.original_filename
  212. else: 0 else
  213. "unknown"
  214. end
  215. mime_type = MIME::Types.type_for(filename).first.to_s
  216. then: 0 else: 0 mime_type = "image/jpeg" if mime_type.empty?
  217. file_data = obj.read
  218. then: 0 else: 0 obj.rewind if obj.respond_to?(:rewind)
  219. base64_string = Base64.strict_encode64(file_data)
  220. "data:#{mime_type};base64,#{base64_string}"
  221. end
  222. end
  223. 1 def strip_responses(messages)
  224. 2 messages.each do |message|
  225. 4 then: 0 else: 4 message.delete(:response) if message.key?(:response)
  226. 4 then: 0 else: 4 message[:content] = JSON.generate(message[:content]) if message[:content].is_a?(Hash)
  227. end
  228. end
  229. 1 def tools
  230. 2 tools_list = []
  231. 2 then: 0 else: 2 if web_search
  232. tools_list << {type: "web_search_preview"}
  233. end
  234. 2 tools_list
  235. end
  236. 1 def extract_text_from_response(response)
  237. response.output.flat_map { it.content }.select { it.is_a?(OpenAI::Models::Responses::ResponseOutputText) }.first.text
  238. end
  239. end
  240. end

lib/ai/response.rb

50.0% lines covered

100.0% branches covered

8 relevant lines. 4 lines covered and 4 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. 1 module AI
  2. 1 class Response
  3. 1 attr_reader :id, :model, :usage, :total_tokens
  4. 1 def initialize(response)
  5. @id = response.id
  6. @model = response.model
  7. @usage = response.usage.to_h.slice(:input_tokens, :output_tokens, :total_tokens)
  8. @total_tokens = @usage[:total_tokens]
  9. end
  10. end
  11. end

openai-ruby/lib/openai.rb

99.81% lines covered

50.0% branches covered

537 relevant lines. 536 lines covered and 1 lines missed.
2 total branches, 1 branches covered and 1 branches missed.
    
  1. # frozen_string_literal: true
  2. # Standard libraries.
  3. 1 require "English"
  4. 1 require "cgi"
  5. 1 require "date"
  6. 1 require "erb"
  7. 1 require "etc"
  8. 1 require "json"
  9. 1 require "net/http"
  10. 1 require "pathname"
  11. 1 require "rbconfig"
  12. 1 require "securerandom"
  13. 1 require "stringio"
  14. 1 require "time"
  15. 1 require "uri"
  16. # We already ship the preferred sorbet manifests in the package itself.
  17. # `tapioca` currently does not offer us a way to opt out of unnecessary compilation.
  18. 1 else: 1 if Object.const_defined?(:Tapioca) &&
  19. caller.chain([$PROGRAM_NAME]).chain(ARGV).any?(/tapioca/) &&
  20. then: 0 ARGV.none?(/dsl/)
  21. return
  22. end
  23. # Gems.
  24. 1 require "connection_pool"
  25. # Package files.
  26. 1 require_relative "openai/version"
  27. 1 require_relative "openai/internal/util"
  28. 1 require_relative "openai/internal/type/converter"
  29. 1 require_relative "openai/internal/type/unknown"
  30. 1 require_relative "openai/internal/type/boolean"
  31. 1 require_relative "openai/internal/type/file_input"
  32. 1 require_relative "openai/internal/type/enum"
  33. 1 require_relative "openai/internal/type/union"
  34. 1 require_relative "openai/internal/type/array_of"
  35. 1 require_relative "openai/internal/type/hash_of"
  36. 1 require_relative "openai/internal/type/base_model"
  37. 1 require_relative "openai/internal/type/base_page"
  38. 1 require_relative "openai/internal/type/base_stream"
  39. 1 require_relative "openai/internal/type/request_parameters"
  40. 1 require_relative "openai/internal"
  41. 1 require_relative "openai/request_options"
  42. 1 require_relative "openai/file_part"
  43. 1 require_relative "openai/errors"
  44. 1 require_relative "openai/internal/transport/base_client"
  45. 1 require_relative "openai/internal/transport/pooled_net_requester"
  46. 1 require_relative "openai/client"
  47. 1 require_relative "openai/internal/stream"
  48. 1 require_relative "openai/internal/cursor_page"
  49. 1 require_relative "openai/internal/page"
  50. 1 require_relative "openai/helpers/structured_output/json_schema_converter"
  51. 1 require_relative "openai/helpers/structured_output/boolean"
  52. 1 require_relative "openai/helpers/structured_output/enum_of"
  53. 1 require_relative "openai/helpers/structured_output/union_of"
  54. 1 require_relative "openai/helpers/structured_output/array_of"
  55. 1 require_relative "openai/helpers/structured_output/base_model"
  56. 1 require_relative "openai/helpers/structured_output/parsed_json"
  57. 1 require_relative "openai/helpers/structured_output"
  58. 1 require_relative "openai/structured_output"
  59. 1 require_relative "openai/models/reasoning_effort"
  60. 1 require_relative "openai/models/chat/chat_completion_message"
  61. 1 require_relative "openai/models/graders/score_model_grader"
  62. 1 require_relative "openai/models/graders/python_grader"
  63. 1 require_relative "openai/models/graders/text_similarity_grader"
  64. 1 require_relative "openai/models/fine_tuning/fine_tuning_job_wandb_integration_object"
  65. 1 require_relative "openai/models/responses/response_function_tool_call"
  66. 1 require_relative "openai/models/all_models"
  67. 1 require_relative "openai/models/audio/speech_create_params"
  68. 1 require_relative "openai/models/audio/speech_model"
  69. 1 require_relative "openai/models/audio/transcription"
  70. 1 require_relative "openai/models/audio/transcription_create_params"
  71. 1 require_relative "openai/models/audio/transcription_create_response"
  72. 1 require_relative "openai/models/audio/transcription_include"
  73. 1 require_relative "openai/models/audio/transcription_segment"
  74. 1 require_relative "openai/models/audio/transcription_stream_event"
  75. 1 require_relative "openai/models/audio/transcription_text_delta_event"
  76. 1 require_relative "openai/models/audio/transcription_text_done_event"
  77. 1 require_relative "openai/models/audio/transcription_verbose"
  78. 1 require_relative "openai/models/audio/transcription_word"
  79. 1 require_relative "openai/models/audio/translation"
  80. 1 require_relative "openai/models/audio/translation_create_params"
  81. 1 require_relative "openai/models/audio/translation_create_response"
  82. 1 require_relative "openai/models/audio/translation_verbose"
  83. 1 require_relative "openai/models/audio_model"
  84. 1 require_relative "openai/models/audio_response_format"
  85. 1 require_relative "openai/models/auto_file_chunking_strategy_param"
  86. 1 require_relative "openai/models/batch"
  87. 1 require_relative "openai/models/batch_cancel_params"
  88. 1 require_relative "openai/models/batch_create_params"
  89. 1 require_relative "openai/models/batch_error"
  90. 1 require_relative "openai/models/batch_list_params"
  91. 1 require_relative "openai/models/batch_request_counts"
  92. 1 require_relative "openai/models/batch_retrieve_params"
  93. 1 require_relative "openai/models/beta/assistant"
  94. 1 require_relative "openai/models/beta/assistant_create_params"
  95. 1 require_relative "openai/models/beta/assistant_deleted"
  96. 1 require_relative "openai/models/beta/assistant_delete_params"
  97. 1 require_relative "openai/models/beta/assistant_list_params"
  98. 1 require_relative "openai/models/beta/assistant_response_format_option"
  99. 1 require_relative "openai/models/beta/assistant_retrieve_params"
  100. 1 require_relative "openai/models/beta/assistant_stream_event"
  101. 1 require_relative "openai/models/beta/assistant_tool"
  102. 1 require_relative "openai/models/beta/assistant_tool_choice"
  103. 1 require_relative "openai/models/beta/assistant_tool_choice_function"
  104. 1 require_relative "openai/models/beta/assistant_tool_choice_option"
  105. 1 require_relative "openai/models/beta/assistant_update_params"
  106. 1 require_relative "openai/models/beta/code_interpreter_tool"
  107. 1 require_relative "openai/models/beta/file_search_tool"
  108. 1 require_relative "openai/models/beta/function_tool"
  109. 1 require_relative "openai/models/beta/message_stream_event"
  110. 1 require_relative "openai/models/beta/run_step_stream_event"
  111. 1 require_relative "openai/models/beta/run_stream_event"
  112. 1 require_relative "openai/models/beta/thread"
  113. 1 require_relative "openai/models/beta/thread_create_and_run_params"
  114. 1 require_relative "openai/models/beta/thread_create_params"
  115. 1 require_relative "openai/models/beta/thread_deleted"
  116. 1 require_relative "openai/models/beta/thread_delete_params"
  117. 1 require_relative "openai/models/beta/thread_retrieve_params"
  118. 1 require_relative "openai/models/beta/threads/annotation"
  119. 1 require_relative "openai/models/beta/threads/annotation_delta"
  120. 1 require_relative "openai/models/beta/threads/file_citation_annotation"
  121. 1 require_relative "openai/models/beta/threads/file_citation_delta_annotation"
  122. 1 require_relative "openai/models/beta/threads/file_path_annotation"
  123. 1 require_relative "openai/models/beta/threads/file_path_delta_annotation"
  124. 1 require_relative "openai/models/beta/threads/image_file"
  125. 1 require_relative "openai/models/beta/threads/image_file_content_block"
  126. 1 require_relative "openai/models/beta/threads/image_file_delta"
  127. 1 require_relative "openai/models/beta/threads/image_file_delta_block"
  128. 1 require_relative "openai/models/beta/threads/image_url"
  129. 1 require_relative "openai/models/beta/threads/image_url_content_block"
  130. 1 require_relative "openai/models/beta/threads/image_url_delta"
  131. 1 require_relative "openai/models/beta/threads/image_url_delta_block"
  132. 1 require_relative "openai/models/beta/threads/message"
  133. 1 require_relative "openai/models/beta/threads/message_content"
  134. 1 require_relative "openai/models/beta/threads/message_content_delta"
  135. 1 require_relative "openai/models/beta/threads/message_content_part_param"
  136. 1 require_relative "openai/models/beta/threads/message_create_params"
  137. 1 require_relative "openai/models/beta/threads/message_deleted"
  138. 1 require_relative "openai/models/beta/threads/message_delete_params"
  139. 1 require_relative "openai/models/beta/threads/message_delta"
  140. 1 require_relative "openai/models/beta/threads/message_delta_event"
  141. 1 require_relative "openai/models/beta/threads/message_list_params"
  142. 1 require_relative "openai/models/beta/threads/message_retrieve_params"
  143. 1 require_relative "openai/models/beta/threads/message_update_params"
  144. 1 require_relative "openai/models/beta/threads/refusal_content_block"
  145. 1 require_relative "openai/models/beta/threads/refusal_delta_block"
  146. 1 require_relative "openai/models/beta/threads/required_action_function_tool_call"
  147. 1 require_relative "openai/models/beta/threads/run"
  148. 1 require_relative "openai/models/beta/threads/run_cancel_params"
  149. 1 require_relative "openai/models/beta/threads/run_create_params"
  150. 1 require_relative "openai/models/beta/threads/run_list_params"
  151. 1 require_relative "openai/models/beta/threads/run_retrieve_params"
  152. 1 require_relative "openai/models/beta/threads/runs/code_interpreter_logs"
  153. 1 require_relative "openai/models/beta/threads/runs/code_interpreter_output_image"
  154. 1 require_relative "openai/models/beta/threads/runs/code_interpreter_tool_call"
  155. 1 require_relative "openai/models/beta/threads/runs/code_interpreter_tool_call_delta"
  156. 1 require_relative "openai/models/beta/threads/runs/file_search_tool_call"
  157. 1 require_relative "openai/models/beta/threads/runs/file_search_tool_call_delta"
  158. 1 require_relative "openai/models/beta/threads/runs/function_tool_call"
  159. 1 require_relative "openai/models/beta/threads/runs/function_tool_call_delta"
  160. 1 require_relative "openai/models/beta/threads/runs/message_creation_step_details"
  161. 1 require_relative "openai/models/beta/threads/runs/run_step"
  162. 1 require_relative "openai/models/beta/threads/runs/run_step_delta"
  163. 1 require_relative "openai/models/beta/threads/runs/run_step_delta_event"
  164. 1 require_relative "openai/models/beta/threads/runs/run_step_delta_message_delta"
  165. 1 require_relative "openai/models/beta/threads/runs/run_step_include"
  166. 1 require_relative "openai/models/beta/threads/runs/step_list_params"
  167. 1 require_relative "openai/models/beta/threads/runs/step_retrieve_params"
  168. 1 require_relative "openai/models/beta/threads/runs/tool_call"
  169. 1 require_relative "openai/models/beta/threads/runs/tool_call_delta"
  170. 1 require_relative "openai/models/beta/threads/runs/tool_call_delta_object"
  171. 1 require_relative "openai/models/beta/threads/runs/tool_calls_step_details"
  172. 1 require_relative "openai/models/beta/threads/run_status"
  173. 1 require_relative "openai/models/beta/threads/run_submit_tool_outputs_params"
  174. 1 require_relative "openai/models/beta/threads/run_update_params"
  175. 1 require_relative "openai/models/beta/threads/text"
  176. 1 require_relative "openai/models/beta/threads/text_content_block"
  177. 1 require_relative "openai/models/beta/threads/text_content_block_param"
  178. 1 require_relative "openai/models/beta/threads/text_delta"
  179. 1 require_relative "openai/models/beta/threads/text_delta_block"
  180. 1 require_relative "openai/models/beta/thread_stream_event"
  181. 1 require_relative "openai/models/beta/thread_update_params"
  182. 1 require_relative "openai/models/chat/chat_completion"
  183. 1 require_relative "openai/models/chat/chat_completion_assistant_message_param"
  184. 1 require_relative "openai/models/chat/chat_completion_audio"
  185. 1 require_relative "openai/models/chat/chat_completion_audio_param"
  186. 1 require_relative "openai/models/chat/chat_completion_chunk"
  187. 1 require_relative "openai/models/chat/chat_completion_content_part"
  188. 1 require_relative "openai/models/chat/chat_completion_content_part_image"
  189. 1 require_relative "openai/models/chat/chat_completion_content_part_input_audio"
  190. 1 require_relative "openai/models/chat/chat_completion_content_part_refusal"
  191. 1 require_relative "openai/models/chat/chat_completion_content_part_text"
  192. 1 require_relative "openai/models/chat/chat_completion_deleted"
  193. 1 require_relative "openai/models/chat/chat_completion_developer_message_param"
  194. 1 require_relative "openai/models/chat/chat_completion_function_call_option"
  195. 1 require_relative "openai/models/chat/chat_completion_function_message_param"
  196. 1 require_relative "openai/models/chat/chat_completion_message_param"
  197. 1 require_relative "openai/models/chat/chat_completion_message_tool_call"
  198. 1 require_relative "openai/models/chat/chat_completion_modality"
  199. 1 require_relative "openai/models/chat/chat_completion_named_tool_choice"
  200. 1 require_relative "openai/models/chat/chat_completion_prediction_content"
  201. 1 require_relative "openai/models/chat/chat_completion_reasoning_effort"
  202. 1 require_relative "openai/models/chat/chat_completion_role"
  203. 1 require_relative "openai/models/chat/chat_completion_store_message"
  204. 1 require_relative "openai/models/chat/chat_completion_stream_options"
  205. 1 require_relative "openai/models/chat/chat_completion_system_message_param"
  206. 1 require_relative "openai/models/chat/chat_completion_token_logprob"
  207. 1 require_relative "openai/models/chat/chat_completion_tool"
  208. 1 require_relative "openai/models/chat/chat_completion_tool_choice_option"
  209. 1 require_relative "openai/models/chat/chat_completion_tool_message_param"
  210. 1 require_relative "openai/models/chat/chat_completion_user_message_param"
  211. 1 require_relative "openai/models/chat/completion_create_params"
  212. 1 require_relative "openai/models/chat/completion_delete_params"
  213. 1 require_relative "openai/models/chat/completion_list_params"
  214. 1 require_relative "openai/models/chat/completion_retrieve_params"
  215. 1 require_relative "openai/models/chat/completions/message_list_params"
  216. 1 require_relative "openai/models/chat/completion_update_params"
  217. 1 require_relative "openai/models/chat_model"
  218. 1 require_relative "openai/models/comparison_filter"
  219. 1 require_relative "openai/models/completion"
  220. 1 require_relative "openai/models/completion_choice"
  221. 1 require_relative "openai/models/completion_create_params"
  222. 1 require_relative "openai/models/completion_usage"
  223. 1 require_relative "openai/models/compound_filter"
  224. 1 require_relative "openai/models/container_create_params"
  225. 1 require_relative "openai/models/container_create_response"
  226. 1 require_relative "openai/models/container_delete_params"
  227. 1 require_relative "openai/models/container_list_params"
  228. 1 require_relative "openai/models/container_list_response"
  229. 1 require_relative "openai/models/container_retrieve_params"
  230. 1 require_relative "openai/models/container_retrieve_response"
  231. 1 require_relative "openai/models/containers/file_create_params"
  232. 1 require_relative "openai/models/containers/file_create_response"
  233. 1 require_relative "openai/models/containers/file_delete_params"
  234. 1 require_relative "openai/models/containers/file_list_params"
  235. 1 require_relative "openai/models/containers/file_list_response"
  236. 1 require_relative "openai/models/containers/file_retrieve_params"
  237. 1 require_relative "openai/models/containers/file_retrieve_response"
  238. 1 require_relative "openai/models/containers/files/content_retrieve_params"
  239. 1 require_relative "openai/models/create_embedding_response"
  240. 1 require_relative "openai/models/embedding"
  241. 1 require_relative "openai/models/embedding_create_params"
  242. 1 require_relative "openai/models/embedding_model"
  243. 1 require_relative "openai/models/error_object"
  244. 1 require_relative "openai/models/eval_create_params"
  245. 1 require_relative "openai/models/eval_create_response"
  246. 1 require_relative "openai/models/eval_custom_data_source_config"
  247. 1 require_relative "openai/models/eval_delete_params"
  248. 1 require_relative "openai/models/eval_delete_response"
  249. 1 require_relative "openai/models/eval_list_params"
  250. 1 require_relative "openai/models/eval_list_response"
  251. 1 require_relative "openai/models/eval_retrieve_params"
  252. 1 require_relative "openai/models/eval_retrieve_response"
  253. 1 require_relative "openai/models/evals/create_eval_completions_run_data_source"
  254. 1 require_relative "openai/models/evals/create_eval_jsonl_run_data_source"
  255. 1 require_relative "openai/models/evals/eval_api_error"
  256. 1 require_relative "openai/models/evals/run_cancel_params"
  257. 1 require_relative "openai/models/evals/run_cancel_response"
  258. 1 require_relative "openai/models/evals/run_create_params"
  259. 1 require_relative "openai/models/evals/run_create_response"
  260. 1 require_relative "openai/models/evals/run_delete_params"
  261. 1 require_relative "openai/models/evals/run_delete_response"
  262. 1 require_relative "openai/models/evals/run_list_params"
  263. 1 require_relative "openai/models/evals/run_list_response"
  264. 1 require_relative "openai/models/evals/run_retrieve_params"
  265. 1 require_relative "openai/models/evals/run_retrieve_response"
  266. 1 require_relative "openai/models/evals/runs/output_item_list_params"
  267. 1 require_relative "openai/models/evals/runs/output_item_list_response"
  268. 1 require_relative "openai/models/evals/runs/output_item_retrieve_params"
  269. 1 require_relative "openai/models/evals/runs/output_item_retrieve_response"
  270. 1 require_relative "openai/models/eval_stored_completions_data_source_config"
  271. 1 require_relative "openai/models/eval_update_params"
  272. 1 require_relative "openai/models/eval_update_response"
  273. 1 require_relative "openai/models/file_chunking_strategy"
  274. 1 require_relative "openai/models/file_chunking_strategy_param"
  275. 1 require_relative "openai/models/file_content"
  276. 1 require_relative "openai/models/file_content_params"
  277. 1 require_relative "openai/models/file_create_params"
  278. 1 require_relative "openai/models/file_deleted"
  279. 1 require_relative "openai/models/file_delete_params"
  280. 1 require_relative "openai/models/file_list_params"
  281. 1 require_relative "openai/models/file_object"
  282. 1 require_relative "openai/models/file_purpose"
  283. 1 require_relative "openai/models/file_retrieve_params"
  284. 1 require_relative "openai/models/fine_tuning/alpha/grader_run_params"
  285. 1 require_relative "openai/models/fine_tuning/alpha/grader_run_response"
  286. 1 require_relative "openai/models/fine_tuning/alpha/grader_validate_params"
  287. 1 require_relative "openai/models/fine_tuning/alpha/grader_validate_response"
  288. 1 require_relative "openai/models/fine_tuning/checkpoints/permission_create_params"
  289. 1 require_relative "openai/models/fine_tuning/checkpoints/permission_create_response"
  290. 1 require_relative "openai/models/fine_tuning/checkpoints/permission_delete_params"
  291. 1 require_relative "openai/models/fine_tuning/checkpoints/permission_delete_response"
  292. 1 require_relative "openai/models/fine_tuning/checkpoints/permission_retrieve_params"
  293. 1 require_relative "openai/models/fine_tuning/checkpoints/permission_retrieve_response"
  294. 1 require_relative "openai/models/fine_tuning/dpo_hyperparameters"
  295. 1 require_relative "openai/models/fine_tuning/dpo_method"
  296. 1 require_relative "openai/models/fine_tuning/fine_tuning_job"
  297. 1 require_relative "openai/models/fine_tuning/fine_tuning_job_event"
  298. 1 require_relative "openai/models/fine_tuning/fine_tuning_job_integration"
  299. 1 require_relative "openai/models/fine_tuning/fine_tuning_job_wandb_integration"
  300. 1 require_relative "openai/models/fine_tuning/job_cancel_params"
  301. 1 require_relative "openai/models/fine_tuning/job_create_params"
  302. 1 require_relative "openai/models/fine_tuning/job_list_events_params"
  303. 1 require_relative "openai/models/fine_tuning/job_list_params"
  304. 1 require_relative "openai/models/fine_tuning/job_pause_params"
  305. 1 require_relative "openai/models/fine_tuning/job_resume_params"
  306. 1 require_relative "openai/models/fine_tuning/job_retrieve_params"
  307. 1 require_relative "openai/models/fine_tuning/jobs/checkpoint_list_params"
  308. 1 require_relative "openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint"
  309. 1 require_relative "openai/models/fine_tuning/reinforcement_hyperparameters"
  310. 1 require_relative "openai/models/fine_tuning/reinforcement_method"
  311. 1 require_relative "openai/models/fine_tuning/supervised_hyperparameters"
  312. 1 require_relative "openai/models/fine_tuning/supervised_method"
  313. 1 require_relative "openai/models/function_definition"
  314. 1 require_relative "openai/models/function_parameters"
  315. 1 require_relative "openai/models/graders/label_model_grader"
  316. 1 require_relative "openai/models/graders/multi_grader"
  317. 1 require_relative "openai/models/graders/string_check_grader"
  318. 1 require_relative "openai/models/image"
  319. 1 require_relative "openai/models/image_create_variation_params"
  320. 1 require_relative "openai/models/image_edit_completed_event"
  321. 1 require_relative "openai/models/image_edit_params"
  322. 1 require_relative "openai/models/image_edit_partial_image_event"
  323. 1 require_relative "openai/models/image_edit_stream_event"
  324. 1 require_relative "openai/models/image_gen_completed_event"
  325. 1 require_relative "openai/models/image_generate_params"
  326. 1 require_relative "openai/models/image_gen_partial_image_event"
  327. 1 require_relative "openai/models/image_gen_stream_event"
  328. 1 require_relative "openai/models/image_model"
  329. 1 require_relative "openai/models/images_response"
  330. 1 require_relative "openai/models/metadata"
  331. 1 require_relative "openai/models/model"
  332. 1 require_relative "openai/models/model_deleted"
  333. 1 require_relative "openai/models/model_delete_params"
  334. 1 require_relative "openai/models/model_list_params"
  335. 1 require_relative "openai/models/model_retrieve_params"
  336. 1 require_relative "openai/models/moderation"
  337. 1 require_relative "openai/models/moderation_create_params"
  338. 1 require_relative "openai/models/moderation_create_response"
  339. 1 require_relative "openai/models/moderation_image_url_input"
  340. 1 require_relative "openai/models/moderation_model"
  341. 1 require_relative "openai/models/moderation_multi_modal_input"
  342. 1 require_relative "openai/models/moderation_text_input"
  343. 1 require_relative "openai/models/other_file_chunking_strategy_object"
  344. 1 require_relative "openai/models/reasoning"
  345. 1 require_relative "openai/models/response_format_json_object"
  346. 1 require_relative "openai/models/response_format_json_schema"
  347. 1 require_relative "openai/models/response_format_text"
  348. 1 require_relative "openai/models/responses/computer_tool"
  349. 1 require_relative "openai/models/responses/easy_input_message"
  350. 1 require_relative "openai/models/responses/file_search_tool"
  351. 1 require_relative "openai/models/responses/function_tool"
  352. 1 require_relative "openai/models/responses/input_item_list_params"
  353. 1 require_relative "openai/models/responses/response"
  354. 1 require_relative "openai/models/responses/response_audio_delta_event"
  355. 1 require_relative "openai/models/responses/response_audio_done_event"
  356. 1 require_relative "openai/models/responses/response_audio_transcript_delta_event"
  357. 1 require_relative "openai/models/responses/response_audio_transcript_done_event"
  358. 1 require_relative "openai/models/responses/response_cancel_params"
  359. 1 require_relative "openai/models/responses/response_code_interpreter_call_code_delta_event"
  360. 1 require_relative "openai/models/responses/response_code_interpreter_call_code_done_event"
  361. 1 require_relative "openai/models/responses/response_code_interpreter_call_completed_event"
  362. 1 require_relative "openai/models/responses/response_code_interpreter_call_in_progress_event"
  363. 1 require_relative "openai/models/responses/response_code_interpreter_call_interpreting_event"
  364. 1 require_relative "openai/models/responses/response_code_interpreter_tool_call"
  365. 1 require_relative "openai/models/responses/response_completed_event"
  366. 1 require_relative "openai/models/responses/response_computer_tool_call"
  367. 1 require_relative "openai/models/responses/response_computer_tool_call_output_item"
  368. 1 require_relative "openai/models/responses/response_computer_tool_call_output_screenshot"
  369. 1 require_relative "openai/models/responses/response_content"
  370. 1 require_relative "openai/models/responses/response_content_part_added_event"
  371. 1 require_relative "openai/models/responses/response_content_part_done_event"
  372. 1 require_relative "openai/models/responses/response_created_event"
  373. 1 require_relative "openai/models/responses/response_create_params"
  374. 1 require_relative "openai/models/responses/response_delete_params"
  375. 1 require_relative "openai/models/responses/response_error"
  376. 1 require_relative "openai/models/responses/response_error_event"
  377. 1 require_relative "openai/models/responses/response_failed_event"
  378. 1 require_relative "openai/models/responses/response_file_search_call_completed_event"
  379. 1 require_relative "openai/models/responses/response_file_search_call_in_progress_event"
  380. 1 require_relative "openai/models/responses/response_file_search_call_searching_event"
  381. 1 require_relative "openai/models/responses/response_file_search_tool_call"
  382. 1 require_relative "openai/models/responses/response_format_text_config"
  383. 1 require_relative "openai/models/responses/response_format_text_json_schema_config"
  384. 1 require_relative "openai/models/responses/response_function_call_arguments_delta_event"
  385. 1 require_relative "openai/models/responses/response_function_call_arguments_done_event"
  386. 1 require_relative "openai/models/responses/response_function_tool_call_item"
  387. 1 require_relative "openai/models/responses/response_function_tool_call_output_item"
  388. 1 require_relative "openai/models/responses/response_function_web_search"
  389. 1 require_relative "openai/models/responses/response_image_gen_call_completed_event"
  390. 1 require_relative "openai/models/responses/response_image_gen_call_generating_event"
  391. 1 require_relative "openai/models/responses/response_image_gen_call_in_progress_event"
  392. 1 require_relative "openai/models/responses/response_image_gen_call_partial_image_event"
  393. 1 require_relative "openai/models/responses/response_includable"
  394. 1 require_relative "openai/models/responses/response_incomplete_event"
  395. 1 require_relative "openai/models/responses/response_in_progress_event"
  396. 1 require_relative "openai/models/responses/response_input"
  397. 1 require_relative "openai/models/responses/response_input_audio"
  398. 1 require_relative "openai/models/responses/response_input_content"
  399. 1 require_relative "openai/models/responses/response_input_file"
  400. 1 require_relative "openai/models/responses/response_input_image"
  401. 1 require_relative "openai/models/responses/response_input_item"
  402. 1 require_relative "openai/models/responses/response_input_message_content_list"
  403. 1 require_relative "openai/models/responses/response_input_message_item"
  404. 1 require_relative "openai/models/responses/response_input_text"
  405. 1 require_relative "openai/models/responses/response_item"
  406. 1 require_relative "openai/models/responses/response_item_list"
  407. 1 require_relative "openai/models/responses/response_mcp_call_arguments_delta_event"
  408. 1 require_relative "openai/models/responses/response_mcp_call_arguments_done_event"
  409. 1 require_relative "openai/models/responses/response_mcp_call_completed_event"
  410. 1 require_relative "openai/models/responses/response_mcp_call_failed_event"
  411. 1 require_relative "openai/models/responses/response_mcp_call_in_progress_event"
  412. 1 require_relative "openai/models/responses/response_mcp_list_tools_completed_event"
  413. 1 require_relative "openai/models/responses/response_mcp_list_tools_failed_event"
  414. 1 require_relative "openai/models/responses/response_mcp_list_tools_in_progress_event"
  415. 1 require_relative "openai/models/responses/response_output_audio"
  416. 1 require_relative "openai/models/responses/response_output_item"
  417. 1 require_relative "openai/models/responses/response_output_item_added_event"
  418. 1 require_relative "openai/models/responses/response_output_item_done_event"
  419. 1 require_relative "openai/models/responses/response_output_message"
  420. 1 require_relative "openai/models/responses/response_output_refusal"
  421. 1 require_relative "openai/models/responses/response_output_text"
  422. 1 require_relative "openai/models/responses/response_output_text_annotation_added_event"
  423. 1 require_relative "openai/models/responses/response_prompt"
  424. 1 require_relative "openai/models/responses/response_queued_event"
  425. 1 require_relative "openai/models/responses/response_reasoning_item"
  426. 1 require_relative "openai/models/responses/response_reasoning_summary_delta_event"
  427. 1 require_relative "openai/models/responses/response_reasoning_summary_done_event"
  428. 1 require_relative "openai/models/responses/response_reasoning_summary_part_added_event"
  429. 1 require_relative "openai/models/responses/response_reasoning_summary_part_done_event"
  430. 1 require_relative "openai/models/responses/response_reasoning_summary_text_delta_event"
  431. 1 require_relative "openai/models/responses/response_reasoning_summary_text_done_event"
  432. 1 require_relative "openai/models/responses/response_refusal_delta_event"
  433. 1 require_relative "openai/models/responses/response_refusal_done_event"
  434. 1 require_relative "openai/models/responses/response_retrieve_params"
  435. 1 require_relative "openai/models/responses/response_status"
  436. 1 require_relative "openai/models/responses/response_stream_event"
  437. 1 require_relative "openai/models/responses/response_text_config"
  438. 1 require_relative "openai/models/responses/response_text_delta_event"
  439. 1 require_relative "openai/models/responses/response_text_done_event"
  440. 1 require_relative "openai/models/responses/response_usage"
  441. 1 require_relative "openai/models/responses/response_web_search_call_completed_event"
  442. 1 require_relative "openai/models/responses/response_web_search_call_in_progress_event"
  443. 1 require_relative "openai/models/responses/response_web_search_call_searching_event"
  444. 1 require_relative "openai/models/responses/tool"
  445. 1 require_relative "openai/models/responses/tool_choice_function"
  446. 1 require_relative "openai/models/responses/tool_choice_mcp"
  447. 1 require_relative "openai/models/responses/tool_choice_options"
  448. 1 require_relative "openai/models/responses/tool_choice_types"
  449. 1 require_relative "openai/models/responses/web_search_tool"
  450. 1 require_relative "openai/models/responses_model"
  451. 1 require_relative "openai/models/static_file_chunking_strategy"
  452. 1 require_relative "openai/models/static_file_chunking_strategy_object"
  453. 1 require_relative "openai/models/static_file_chunking_strategy_object_param"
  454. 1 require_relative "openai/models/upload"
  455. 1 require_relative "openai/models/upload_cancel_params"
  456. 1 require_relative "openai/models/upload_complete_params"
  457. 1 require_relative "openai/models/upload_create_params"
  458. 1 require_relative "openai/models/uploads/part_create_params"
  459. 1 require_relative "openai/models/uploads/upload_part"
  460. 1 require_relative "openai/models/vector_store"
  461. 1 require_relative "openai/models/vector_store_create_params"
  462. 1 require_relative "openai/models/vector_store_deleted"
  463. 1 require_relative "openai/models/vector_store_delete_params"
  464. 1 require_relative "openai/models/vector_store_list_params"
  465. 1 require_relative "openai/models/vector_store_retrieve_params"
  466. 1 require_relative "openai/models/vector_stores/file_batch_cancel_params"
  467. 1 require_relative "openai/models/vector_stores/file_batch_create_params"
  468. 1 require_relative "openai/models/vector_stores/file_batch_list_files_params"
  469. 1 require_relative "openai/models/vector_stores/file_batch_retrieve_params"
  470. 1 require_relative "openai/models/vector_stores/file_content_params"
  471. 1 require_relative "openai/models/vector_stores/file_content_response"
  472. 1 require_relative "openai/models/vector_stores/file_create_params"
  473. 1 require_relative "openai/models/vector_stores/file_delete_params"
  474. 1 require_relative "openai/models/vector_stores/file_list_params"
  475. 1 require_relative "openai/models/vector_stores/file_retrieve_params"
  476. 1 require_relative "openai/models/vector_stores/file_update_params"
  477. 1 require_relative "openai/models/vector_stores/vector_store_file"
  478. 1 require_relative "openai/models/vector_stores/vector_store_file_batch"
  479. 1 require_relative "openai/models/vector_stores/vector_store_file_deleted"
  480. 1 require_relative "openai/models/vector_store_search_params"
  481. 1 require_relative "openai/models/vector_store_search_response"
  482. 1 require_relative "openai/models/vector_store_update_params"
  483. 1 require_relative "openai/models/webhooks/batch_cancelled_webhook_event"
  484. 1 require_relative "openai/models/webhooks/batch_completed_webhook_event"
  485. 1 require_relative "openai/models/webhooks/batch_expired_webhook_event"
  486. 1 require_relative "openai/models/webhooks/batch_failed_webhook_event"
  487. 1 require_relative "openai/models/webhooks/eval_run_canceled_webhook_event"
  488. 1 require_relative "openai/models/webhooks/eval_run_failed_webhook_event"
  489. 1 require_relative "openai/models/webhooks/eval_run_succeeded_webhook_event"
  490. 1 require_relative "openai/models/webhooks/fine_tuning_job_cancelled_webhook_event"
  491. 1 require_relative "openai/models/webhooks/fine_tuning_job_failed_webhook_event"
  492. 1 require_relative "openai/models/webhooks/fine_tuning_job_succeeded_webhook_event"
  493. 1 require_relative "openai/models/webhooks/response_cancelled_webhook_event"
  494. 1 require_relative "openai/models/webhooks/response_completed_webhook_event"
  495. 1 require_relative "openai/models/webhooks/response_failed_webhook_event"
  496. 1 require_relative "openai/models/webhooks/response_incomplete_webhook_event"
  497. 1 require_relative "openai/models/webhooks/unwrap_webhook_event"
  498. 1 require_relative "openai/models/webhooks/webhook_unwrap_params"
  499. 1 require_relative "openai/models"
  500. 1 require_relative "openai/resources/audio"
  501. 1 require_relative "openai/resources/audio/speech"
  502. 1 require_relative "openai/resources/audio/transcriptions"
  503. 1 require_relative "openai/resources/audio/translations"
  504. 1 require_relative "openai/resources/batches"
  505. 1 require_relative "openai/resources/beta"
  506. 1 require_relative "openai/resources/beta/assistants"
  507. 1 require_relative "openai/resources/beta/threads"
  508. 1 require_relative "openai/resources/beta/threads/messages"
  509. 1 require_relative "openai/resources/beta/threads/runs"
  510. 1 require_relative "openai/resources/beta/threads/runs/steps"
  511. 1 require_relative "openai/resources/chat"
  512. 1 require_relative "openai/resources/chat/completions"
  513. 1 require_relative "openai/resources/chat/completions/messages"
  514. 1 require_relative "openai/resources/completions"
  515. 1 require_relative "openai/resources/containers"
  516. 1 require_relative "openai/resources/containers/files"
  517. 1 require_relative "openai/resources/containers/files/content"
  518. 1 require_relative "openai/resources/embeddings"
  519. 1 require_relative "openai/resources/evals"
  520. 1 require_relative "openai/resources/evals/runs"
  521. 1 require_relative "openai/resources/evals/runs/output_items"
  522. 1 require_relative "openai/resources/files"
  523. 1 require_relative "openai/resources/fine_tuning"
  524. 1 require_relative "openai/resources/fine_tuning/alpha"
  525. 1 require_relative "openai/resources/fine_tuning/alpha/graders"
  526. 1 require_relative "openai/resources/fine_tuning/checkpoints"
  527. 1 require_relative "openai/resources/fine_tuning/checkpoints/permissions"
  528. 1 require_relative "openai/resources/fine_tuning/jobs"
  529. 1 require_relative "openai/resources/fine_tuning/jobs/checkpoints"
  530. 1 require_relative "openai/resources/fine_tuning/methods"
  531. 1 require_relative "openai/resources/graders"
  532. 1 require_relative "openai/resources/graders/grader_models"
  533. 1 require_relative "openai/resources/images"
  534. 1 require_relative "openai/resources/models"
  535. 1 require_relative "openai/resources/moderations"
  536. 1 require_relative "openai/resources/responses"
  537. 1 require_relative "openai/resources/responses/input_items"
  538. 1 require_relative "openai/resources/uploads"
  539. 1 require_relative "openai/resources/uploads/parts"
  540. 1 require_relative "openai/resources/vector_stores"
  541. 1 require_relative "openai/resources/vector_stores/file_batches"
  542. 1 require_relative "openai/resources/vector_stores/files"
  543. 1 require_relative "openai/resources/webhooks"
  544. 1 require_relative "openai/helpers/streaming/events"
  545. 1 require_relative "openai/helpers/streaming/response_stream"
  546. 1 require_relative "openai/streaming"

openai-ruby/lib/openai/client.rb

98.28% lines covered

50.0% branches covered

58 relevant lines. 57 lines covered and 1 lines missed.
10 total branches, 5 branches covered and 5 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 class Client < OpenAI::Internal::Transport::BaseClient
  4. # Default max number of retries to attempt after a failed retryable request.
  5. 1 DEFAULT_MAX_RETRIES = 2
  6. # Default per-request timeout.
  7. 1 DEFAULT_TIMEOUT_IN_SECONDS = 600.0
  8. # Default initial retry delay in seconds.
  9. # Overall delay is calculated using exponential backoff + jitter.
  10. 1 DEFAULT_INITIAL_RETRY_DELAY = 0.5
  11. # Default max retry delay in seconds.
  12. 1 DEFAULT_MAX_RETRY_DELAY = 8.0
  13. # @return [String]
  14. 1 attr_reader :api_key
  15. # @return [String, nil]
  16. 1 attr_reader :organization
  17. # @return [String, nil]
  18. 1 attr_reader :project
  19. # @return [String, nil]
  20. 1 attr_reader :webhook_secret
  21. # @return [OpenAI::Resources::Completions]
  22. 1 attr_reader :completions
  23. # @return [OpenAI::Resources::Chat]
  24. 1 attr_reader :chat
  25. # @return [OpenAI::Resources::Embeddings]
  26. 1 attr_reader :embeddings
  27. # @return [OpenAI::Resources::Files]
  28. 1 attr_reader :files
  29. # @return [OpenAI::Resources::Images]
  30. 1 attr_reader :images
  31. # @return [OpenAI::Resources::Audio]
  32. 1 attr_reader :audio
  33. # @return [OpenAI::Resources::Moderations]
  34. 1 attr_reader :moderations
  35. # @return [OpenAI::Resources::Models]
  36. 1 attr_reader :models
  37. # @return [OpenAI::Resources::FineTuning]
  38. 1 attr_reader :fine_tuning
  39. # @return [OpenAI::Resources::Graders]
  40. 1 attr_reader :graders
  41. # @return [OpenAI::Resources::VectorStores]
  42. 1 attr_reader :vector_stores
  43. # @return [OpenAI::Resources::Webhooks]
  44. 1 attr_reader :webhooks
  45. # @return [OpenAI::Resources::Beta]
  46. 1 attr_reader :beta
  47. # @return [OpenAI::Resources::Batches]
  48. 1 attr_reader :batches
  49. # @return [OpenAI::Resources::Uploads]
  50. 1 attr_reader :uploads
  51. # @return [OpenAI::Resources::Responses]
  52. 1 attr_reader :responses
  53. # @return [OpenAI::Resources::Evals]
  54. 1 attr_reader :evals
  55. # @return [OpenAI::Resources::Containers]
  56. 1 attr_reader :containers
  57. # @api private
  58. #
  59. # @return [Hash{String=>String}]
  60. 1 private def auth_headers
  61. 2 then: 0 else: 2 return {} if @api_key.nil?
  62. 2 {"authorization" => "Bearer #{@api_key}"}
  63. end
  64. # Creates and returns a new client for interacting with the API.
  65. #
  66. # @param api_key [String, nil] Defaults to `ENV["OPENAI_API_KEY"]`
  67. #
  68. # @param organization [String, nil] Defaults to `ENV["OPENAI_ORG_ID"]`
  69. #
  70. # @param project [String, nil] Defaults to `ENV["OPENAI_PROJECT_ID"]`
  71. #
  72. # @param webhook_secret [String, nil] Defaults to `ENV["OPENAI_WEBHOOK_SECRET"]`
  73. #
  74. # @param base_url [String, nil] Override the default base URL for the API, e.g.,
  75. # `"https://api.example.com/v2/"`. Defaults to `ENV["OPENAI_BASE_URL"]`
  76. #
  77. # @param max_retries [Integer] Max number of retries to attempt after a failed retryable request.
  78. #
  79. # @param timeout [Float]
  80. #
  81. # @param initial_retry_delay [Float]
  82. #
  83. # @param max_retry_delay [Float]
  84. 1 def initialize(
  85. api_key: ENV["OPENAI_API_KEY"],
  86. organization: ENV["OPENAI_ORG_ID"],
  87. project: ENV["OPENAI_PROJECT_ID"],
  88. webhook_secret: ENV["OPENAI_WEBHOOK_SECRET"],
  89. base_url: ENV["OPENAI_BASE_URL"],
  90. max_retries: self.class::DEFAULT_MAX_RETRIES,
  91. timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS,
  92. initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY,
  93. max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY
  94. )
  95. 2 base_url ||= "https://api.openai.com/v1"
  96. 2 then: 0 else: 2 if api_key.nil?
  97. raise ArgumentError.new("api_key is required, and can be set via environ: \"OPENAI_API_KEY\"")
  98. end
  99. headers = {
  100. 4 then: 0 else: 2 "openai-organization" => (@organization = organization&.to_s),
  101. 2 then: 0 else: 2 "openai-project" => (@project = project&.to_s)
  102. }
  103. 2 @api_key = api_key.to_s
  104. 2 then: 0 else: 2 @webhook_secret = webhook_secret&.to_s
  105. 2 super(
  106. base_url: base_url,
  107. timeout: timeout,
  108. max_retries: max_retries,
  109. initial_retry_delay: initial_retry_delay,
  110. max_retry_delay: max_retry_delay,
  111. headers: headers
  112. )
  113. 2 @completions = OpenAI::Resources::Completions.new(client: self)
  114. 2 @chat = OpenAI::Resources::Chat.new(client: self)
  115. 2 @embeddings = OpenAI::Resources::Embeddings.new(client: self)
  116. 2 @files = OpenAI::Resources::Files.new(client: self)
  117. 2 @images = OpenAI::Resources::Images.new(client: self)
  118. 2 @audio = OpenAI::Resources::Audio.new(client: self)
  119. 2 @moderations = OpenAI::Resources::Moderations.new(client: self)
  120. 2 @models = OpenAI::Resources::Models.new(client: self)
  121. 2 @fine_tuning = OpenAI::Resources::FineTuning.new(client: self)
  122. 2 @graders = OpenAI::Resources::Graders.new(client: self)
  123. 2 @vector_stores = OpenAI::Resources::VectorStores.new(client: self)
  124. 2 @webhooks = OpenAI::Resources::Webhooks.new(client: self)
  125. 2 @beta = OpenAI::Resources::Beta.new(client: self)
  126. 2 @batches = OpenAI::Resources::Batches.new(client: self)
  127. 2 @uploads = OpenAI::Resources::Uploads.new(client: self)
  128. 2 @responses = OpenAI::Resources::Responses.new(client: self)
  129. 2 @evals = OpenAI::Resources::Evals.new(client: self)
  130. 2 @containers = OpenAI::Resources::Containers.new(client: self)
  131. end
  132. end
  133. end

openai-ruby/lib/openai/errors.rb

78.79% lines covered

15.38% branches covered

66 relevant lines. 52 lines covered and 14 lines missed.
13 total branches, 2 branches covered and 11 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Errors
  4. 1 class Error < StandardError
  5. # @!attribute cause
  6. #
  7. # @return [StandardError, nil]
  8. end
  9. 1 class InvalidWebhookSignatureError < OpenAI::Errors::Error
  10. end
  11. 1 class ConversionError < OpenAI::Errors::Error
  12. # @return [StandardError, nil]
  13. 1 then: 0 else: 0 def cause = @cause.nil? ? super : @cause
  14. # @api private
  15. #
  16. # @param on [Class<StandardError>]
  17. # @param method [Symbol]
  18. # @param target [Object]
  19. # @param value [Object]
  20. # @param cause [StandardError, nil]
  21. 1 def initialize(on:, method:, target:, value:, cause: nil)
  22. cls = on.name.split("::").last
  23. message = [
  24. "Failed to parse #{cls}.#{method} from #{value.class} to #{target.inspect}.",
  25. "To get the unparsed API response, use #{cls}[#{method.inspect}].",
  26. cause && "Cause: #{cause.message}"
  27. ].filter(&:itself).join(" ")
  28. @cause = cause
  29. super(message)
  30. end
  31. end
  32. 1 class APIError < OpenAI::Errors::Error
  33. # @return [URI::Generic]
  34. 1 attr_accessor :url
  35. # @return [Integer, nil]
  36. 1 attr_accessor :status
  37. # @return [Object, nil]
  38. 1 attr_accessor :body
  39. # @return [String, nil]
  40. 1 attr_accessor :code
  41. # @return [String, nil]
  42. 1 attr_accessor :param
  43. # @return [String, nil]
  44. 1 attr_accessor :type
  45. # @api private
  46. #
  47. # @param url [URI::Generic]
  48. # @param status [Integer, nil]
  49. # @param body [Object, nil]
  50. # @param request [nil]
  51. # @param response [nil]
  52. # @param message [String, nil]
  53. 1 def initialize(url:, status: nil, body: nil, request: nil, response: nil, message: nil)
  54. 2 @url = url
  55. 2 @status = status
  56. 2 @body = body
  57. 2 @request = request
  58. 2 @response = response
  59. 2 super(message)
  60. end
  61. end
  62. 1 class APIConnectionError < OpenAI::Errors::APIError
  63. # @!attribute status
  64. #
  65. # @return [nil]
  66. # @!attribute body
  67. #
  68. # @return [nil]
  69. # @!attribute code
  70. #
  71. # @return [nil]
  72. # @!attribute param
  73. #
  74. # @return [nil]
  75. # @!attribute type
  76. #
  77. # @return [nil]
  78. # @api private
  79. #
  80. # @param url [URI::Generic]
  81. # @param status [nil]
  82. # @param body [nil]
  83. # @param request [nil]
  84. # @param response [nil]
  85. # @param message [String, nil]
  86. 1 def initialize(
  87. url:,
  88. status: nil,
  89. body: nil,
  90. request: nil,
  91. response: nil,
  92. message: "Connection error."
  93. )
  94. super
  95. end
  96. end
  97. 1 class APITimeoutError < OpenAI::Errors::APIConnectionError
  98. # @api private
  99. #
  100. # @param url [URI::Generic]
  101. # @param status [nil]
  102. # @param body [nil]
  103. # @param request [nil]
  104. # @param response [nil]
  105. # @param message [String, nil]
  106. 1 def initialize(
  107. url:,
  108. status: nil,
  109. body: nil,
  110. request: nil,
  111. response: nil,
  112. message: "Request timed out."
  113. )
  114. super
  115. end
  116. end
  117. 1 class APIStatusError < OpenAI::Errors::APIError
  118. # @api private
  119. #
  120. # @param url [URI::Generic]
  121. # @param status [Integer]
  122. # @param body [Object, nil]
  123. # @param request [nil]
  124. # @param response [nil]
  125. # @param message [String, nil]
  126. #
  127. # @return [self]
  128. 1 def self.for(url:, status:, body:, request:, response:, message: nil)
  129. kwargs = {
  130. 2 url: url,
  131. status: status,
  132. body: body,
  133. request: request,
  134. response: response,
  135. message: message
  136. }
  137. case status
  138. 2 in: 2 in 400
  139. 2 OpenAI::Errors::BadRequestError.new(**kwargs)
  140. in: 0 in 401
  141. OpenAI::Errors::AuthenticationError.new(**kwargs)
  142. in: 0 in 403
  143. OpenAI::Errors::PermissionDeniedError.new(**kwargs)
  144. in: 0 in 404
  145. OpenAI::Errors::NotFoundError.new(**kwargs)
  146. in: 0 in 409
  147. OpenAI::Errors::ConflictError.new(**kwargs)
  148. in: 0 in 422
  149. OpenAI::Errors::UnprocessableEntityError.new(**kwargs)
  150. in: 0 in 429
  151. OpenAI::Errors::RateLimitError.new(**kwargs)
  152. in: 0 in (500..)
  153. OpenAI::Errors::InternalServerError.new(**kwargs)
  154. else: 0 else
  155. OpenAI::Errors::APIStatusError.new(**kwargs)
  156. end
  157. end
  158. # @!parse
  159. # # @return [Integer]
  160. # attr_accessor :status
  161. # @!parse
  162. # # @return [String, nil]
  163. # attr_accessor :code
  164. # @!parse
  165. # # @return [String, nil]
  166. # attr_accessor :param
  167. # @!parse
  168. # # @return [String, nil]
  169. # attr_accessor :type
  170. # @api private
  171. #
  172. # @param url [URI::Generic]
  173. # @param status [Integer]
  174. # @param body [Object, nil]
  175. # @param request [nil]
  176. # @param response [nil]
  177. # @param message [String, nil]
  178. 1 def initialize(url:, status:, body:, request:, response:, message: nil)
  179. 4 message ||= OpenAI::Internal::Util.dig(body, :message) { {url: url.to_s, status: status, body: body} }
  180. 2 @code = OpenAI::Internal::Type::Converter.coerce(String, OpenAI::Internal::Util.dig(body, :code))
  181. 2 @param = OpenAI::Internal::Type::Converter.coerce(String, OpenAI::Internal::Util.dig(body, :param))
  182. 2 @type = OpenAI::Internal::Type::Converter.coerce(String, OpenAI::Internal::Util.dig(body, :type))
  183. 2 super(
  184. url: url,
  185. status: status,
  186. body: body,
  187. request: request,
  188. response: response,
  189. then: 2 else: 0 message: message&.to_s
  190. )
  191. end
  192. end
  193. 1 class BadRequestError < OpenAI::Errors::APIStatusError
  194. 1 HTTP_STATUS = 400
  195. end
  196. 1 class AuthenticationError < OpenAI::Errors::APIStatusError
  197. 1 HTTP_STATUS = 401
  198. end
  199. 1 class PermissionDeniedError < OpenAI::Errors::APIStatusError
  200. 1 HTTP_STATUS = 403
  201. end
  202. 1 class NotFoundError < OpenAI::Errors::APIStatusError
  203. 1 HTTP_STATUS = 404
  204. end
  205. 1 class ConflictError < OpenAI::Errors::APIStatusError
  206. 1 HTTP_STATUS = 409
  207. end
  208. 1 class UnprocessableEntityError < OpenAI::Errors::APIStatusError
  209. 1 HTTP_STATUS = 422
  210. end
  211. 1 class RateLimitError < OpenAI::Errors::APIStatusError
  212. 1 HTTP_STATUS = 429
  213. end
  214. 1 class InternalServerError < OpenAI::Errors::APIStatusError
  215. 1 HTTP_STATUS = (500..)
  216. end
  217. end
  218. end

openai-ruby/lib/openai/file_part.rb

47.37% lines covered

0.0% branches covered

19 relevant lines. 9 lines covered and 10 lines missed.
11 total branches, 0 branches covered and 11 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 class FilePart
  4. # @return [Pathname, StringIO, IO, String]
  5. 1 attr_reader :content
  6. # @return [String, nil]
  7. 1 attr_reader :content_type
  8. # @return [String, nil]
  9. 1 attr_reader :filename
  10. # @api private
  11. #
  12. # @return [String]
  13. 1 private def read
  14. else: 0 case content
  15. in: 0 in Pathname
  16. content.read(binmode: true)
  17. in: 0 in StringIO
  18. content.string
  19. in: 0 in IO
  20. content.read
  21. in: 0 in String
  22. content
  23. end
  24. end
  25. # @param a [Object]
  26. #
  27. # @return [String]
  28. 1 def to_json(*a) = read.to_json(*a)
  29. # @param a [Object]
  30. #
  31. # @return [String]
  32. 1 def to_yaml(*a) = read.to_yaml(*a)
  33. # @param content [Pathname, StringIO, IO, String]
  34. # @param filename [String, nil]
  35. # @param content_type [String, nil]
  36. 1 def initialize(content, filename: nil, content_type: nil)
  37. @content = content
  38. @filename =
  39. case content
  40. in: 0 in Pathname
  41. then: 0 else: 0 filename.nil? ? content.basename.to_path : ::File.basename(filename)
  42. else: 0 else
  43. then: 0 else: 0 filename.nil? ? nil : ::File.basename(filename)
  44. end
  45. @content_type = content_type
  46. end
  47. end
  48. end

openai-ruby/lib/openai/helpers/streaming/events.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Helpers
  4. 1 module Streaming
  5. 1 class ResponseTextDeltaEvent < OpenAI::Models::Responses::ResponseTextDeltaEvent
  6. 1 required :snapshot, String
  7. end
  8. 1 class ResponseTextDoneEvent < OpenAI::Models::Responses::ResponseTextDoneEvent
  9. 1 optional :parsed, Object
  10. end
  11. 1 class ResponseFunctionCallArgumentsDeltaEvent < OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent
  12. 1 required :snapshot, String
  13. end
  14. 1 class ResponseCompletedEvent < OpenAI::Models::Responses::ResponseCompletedEvent
  15. 1 required :response, OpenAI::Models::Responses::Response
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/helpers/streaming/response_stream.rb

20.19% lines covered

0.0% branches covered

104 relevant lines. 21 lines covered and 83 lines missed.
39 total branches, 0 branches covered and 39 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require_relative "events"
  3. 1 module OpenAI
  4. 1 module Helpers
  5. 1 module Streaming
  6. 1 class ResponseStream
  7. 1 include OpenAI::Internal::Type::BaseStream
  8. 1 def initialize(raw_stream:, text_format: nil, starting_after: nil)
  9. @text_format = text_format
  10. @starting_after = starting_after
  11. @raw_stream = raw_stream
  12. @iterator = iterator
  13. @state = ResponseStreamState.new(
  14. text_format: text_format
  15. )
  16. end
  17. 1 def until_done
  18. each {} # rubocop:disable Lint/EmptyBlock
  19. self
  20. end
  21. 1 def text
  22. OpenAI::Internal::Util.chain_fused(@iterator) do |yielder|
  23. @iterator.each do |event|
  24. else: 0 case event
  25. when: 0 when OpenAI::Streaming::ResponseTextDeltaEvent
  26. yielder << event.delta
  27. end
  28. end
  29. end
  30. end
  31. 1 def get_final_response
  32. until_done
  33. response = @state.completed_response
  34. else: 0 then: 0 raise RuntimeError.new("Didn't receive a 'response.completed' event") unless response
  35. response
  36. end
  37. 1 def get_output_text
  38. response = get_final_response
  39. text_parts = []
  40. response.output.each do |output|
  41. else: 0 then: 0 next unless output.type == :message
  42. output.content.each do |content|
  43. else: 0 then: 0 next unless content.type == :output_text
  44. text_parts << content.text
  45. end
  46. end
  47. text_parts.join
  48. end
  49. 1 private
  50. 1 def iterator
  51. @iterator ||= OpenAI::Internal::Util.chain_fused(@raw_stream) do |y|
  52. @raw_stream.each do |raw_event|
  53. events_to_yield = @state.handle_event(raw_event)
  54. events_to_yield.each do |event|
  55. then: 0 else: 0 if @starting_after.nil? || event.sequence_number > @starting_after
  56. y << event
  57. end
  58. end
  59. end
  60. end
  61. end
  62. end
  63. 1 class ResponseStreamState
  64. 1 attr_reader :completed_response
  65. 1 def initialize(text_format:)
  66. @current_snapshot = nil
  67. @completed_response = nil
  68. @text_format = text_format
  69. end
  70. 1 def handle_event(event)
  71. @current_snapshot = accumulate_event(
  72. event: event,
  73. current_snapshot: @current_snapshot
  74. )
  75. events_to_yield = []
  76. case event
  77. when: 0 when OpenAI::Models::Responses::ResponseTextDeltaEvent
  78. output = @current_snapshot.output[event.output_index]
  79. assert_type(output, :message)
  80. content = output.content[event.content_index]
  81. assert_type(content, :output_text)
  82. events_to_yield << OpenAI::Streaming::ResponseTextDeltaEvent.new(
  83. content_index: event.content_index,
  84. delta: event.delta,
  85. item_id: event.item_id,
  86. output_index: event.output_index,
  87. sequence_number: event.sequence_number,
  88. type: event.type,
  89. snapshot: content.text
  90. )
  91. when: 0 when OpenAI::Models::Responses::ResponseTextDoneEvent
  92. output = @current_snapshot.output[event.output_index]
  93. assert_type(output, :message)
  94. content = output.content[event.content_index]
  95. assert_type(content, :output_text)
  96. parsed = parse_structured_text(content.text)
  97. events_to_yield << OpenAI::Streaming::ResponseTextDoneEvent.new(
  98. content_index: event.content_index,
  99. item_id: event.item_id,
  100. output_index: event.output_index,
  101. sequence_number: event.sequence_number,
  102. text: event.text,
  103. type: event.type,
  104. parsed: parsed
  105. )
  106. when: 0 when OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent
  107. output = @current_snapshot.output[event.output_index]
  108. assert_type(output, :function_call)
  109. events_to_yield << OpenAI::Streaming::ResponseFunctionCallArgumentsDeltaEvent.new(
  110. delta: event.delta,
  111. item_id: event.item_id,
  112. output_index: event.output_index,
  113. sequence_number: event.sequence_number,
  114. type: event.type,
  115. snapshot: output.arguments
  116. )
  117. when: 0 when OpenAI::Models::Responses::ResponseCompletedEvent
  118. events_to_yield << OpenAI::Streaming::ResponseCompletedEvent.new(
  119. sequence_number: event.sequence_number,
  120. type: event.type,
  121. response: event.response
  122. )
  123. else
  124. else: 0 # Pass through other events unchanged.
  125. events_to_yield << event
  126. end
  127. events_to_yield
  128. end
  129. 1 def accumulate_event(event:, current_snapshot:)
  130. then: 0 else: 0 if current_snapshot.nil?
  131. else: 0 then: 0 unless event.is_a?(OpenAI::Models::Responses::ResponseCreatedEvent)
  132. raise "Expected first event to be response.created"
  133. end
  134. # Use the converter to create a new, isolated copy of the response object.
  135. # This ensures proper type validation and prevents shared object references.
  136. return OpenAI::Internal::Type::Converter.coerce(
  137. OpenAI::Models::Responses::Response,
  138. event.response
  139. )
  140. end
  141. else: 0 case event
  142. when: 0 when OpenAI::Models::Responses::ResponseOutputItemAddedEvent
  143. current_snapshot.output.push(event.item)
  144. when: 0 when OpenAI::Models::Responses::ResponseContentPartAddedEvent
  145. output = current_snapshot.output[event.output_index]
  146. then: 0 else: 0 if output && output.type == :message
  147. output.content.push(event.part)
  148. current_snapshot.output[event.output_index] = output
  149. end
  150. when: 0 when OpenAI::Models::Responses::ResponseTextDeltaEvent
  151. output = current_snapshot.output[event.output_index]
  152. then: 0 else: 0 if output && output.type == :message
  153. content = output.content[event.content_index]
  154. then: 0 else: 0 if content && content.type == :output_text
  155. content.text += event.delta
  156. output.content[event.content_index] = content
  157. current_snapshot.output[event.output_index] = output
  158. end
  159. end
  160. when: 0 when OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent
  161. output = current_snapshot.output[event.output_index]
  162. then: 0 else: 0 if output && output.type == :function_call
  163. output.arguments = (output.arguments || "") + event.delta
  164. current_snapshot.output[event.output_index] = output
  165. end
  166. when: 0 when OpenAI::Models::Responses::ResponseCompletedEvent
  167. @completed_response = event.response
  168. end
  169. current_snapshot
  170. end
  171. 1 private
  172. 1 def assert_type(object, expected_type)
  173. then: 0 else: 0 return if object && object.type == expected_type
  174. then: 0 else: 0 actual_type = object ? object.type : "nil"
  175. raise "Invalid state: expected #{expected_type} but got #{actual_type}"
  176. end
  177. 1 def parse_structured_text(text)
  178. else: 0 then: 0 return nil unless @text_format && text
  179. begin
  180. parsed = JSON.parse(text, symbolize_names: true)
  181. OpenAI::Internal::Type::Converter.coerce(@text_format, parsed)
  182. rescue JSON::ParserError => e
  183. raise RuntimeError.new(
  184. "Failed to parse structured text as JSON for #{@text_format}: #{e.message}. " \
  185. "Raw text: #{text.inspect}"
  186. )
  187. end
  188. end
  189. end
  190. end
  191. end
  192. end

openai-ruby/lib/openai/helpers/structured_output.rb

100.0% lines covered

100.0% branches covered

3 relevant lines. 3 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Helpers
  4. # Helpers for the structured output API.
  5. #
  6. # see https://platform.openai.com/docs/guides/structured-outputs
  7. # see https://json-schema.org
  8. #
  9. # Based on the DSL in {OpenAI::Internal::Type}, but currently only support the limited subset of JSON schema types used in structured output APIs.
  10. #
  11. # Supported types: {NilClass} {String} {Symbol} {Integer} {Float} {OpenAI::Boolean}, {OpenAI::EnumOf}, {OpenAI::UnionOf}, {OpenAI::ArrayOf}, {OpenAI::BaseModel}
  12. 1 module StructuredOutput
  13. end
  14. end
  15. end

openai-ruby/lib/openai/helpers/structured_output/array_of.rb

50.0% lines covered

0.0% branches covered

16 relevant lines. 8 lines covered and 8 lines missed.
4 total branches, 0 branches covered and 4 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Helpers
  4. 1 module StructuredOutput
  5. # @generic Elem
  6. #
  7. # @example
  8. # example = OpenAI::ArrayOf[Integer]
  9. #
  10. # @example
  11. # example = OpenAI::ArrayOf[Integer, nil?: true, doc: "hi there!"]
  12. 1 class ArrayOf < OpenAI::Internal::Type::ArrayOf
  13. 1 include OpenAI::Helpers::StructuredOutput::JsonSchemaConverter
  14. # @api private
  15. #
  16. # @param state [Hash{Symbol=>Object}]
  17. #
  18. # @option state [Hash{Object=>String}] :defs
  19. #
  20. # @option state [Array<String>] :path
  21. #
  22. # @return [Hash{Symbol=>Object}]
  23. 1 def to_json_schema_inner(state:)
  24. OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.cache_def!(state, type: self) do
  25. state.fetch(:path) << "[]"
  26. items = OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_json_schema_inner(
  27. item_type,
  28. state: state
  29. )
  30. then: 0 else: 0 items = OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_nilable(items) if nilable?
  31. schema = {type: "array", items: items}
  32. then: 0 else: 0 description.nil? ? schema : schema.update(description: description)
  33. end
  34. end
  35. # @return [String, nil]
  36. 1 attr_reader :description
  37. 1 def initialize(type_info, spec = {})
  38. super
  39. @description = [type_info, spec].grep(Hash).filter_map { _1[:doc] }.first
  40. end
  41. end
  42. end
  43. end
  44. end

openai-ruby/lib/openai/helpers/structured_output/base_model.rb

39.29% lines covered

0.0% branches covered

28 relevant lines. 11 lines covered and 17 lines missed.
7 total branches, 0 branches covered and 7 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Helpers
  4. 1 module StructuredOutput
  5. # Represents a response from OpenAI's API where the model's output has been structured according to a schema predefined by the user.
  6. #
  7. # This class is specifically used when making requests with the `response_format` parameter set to use structured output (e.g., JSON).
  8. #
  9. # See {examples/structured_outputs_chat_completions.rb} for a complete example of use
  10. 1 class BaseModel < OpenAI::Internal::Type::BaseModel
  11. 1 extend OpenAI::Helpers::StructuredOutput::JsonSchemaConverter
  12. 1 class << self
  13. # @return [Hash{Symbol=>Object}]
  14. 1 def to_json_schema = OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_json_schema(self)
  15. # @api private
  16. #
  17. # @param state [Hash{Symbol=>Object}]
  18. #
  19. # @option state [Hash{Object=>String}] :defs
  20. #
  21. # @option state [Array<String>] :path
  22. #
  23. # @return [Hash{Symbol=>Object}]
  24. 1 def to_json_schema_inner(state:)
  25. OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.cache_def!(state, type: self) do
  26. path = state.fetch(:path)
  27. properties = fields.to_h do |name, field|
  28. type, nilable = field.fetch_values(:type, :nilable)
  29. new_state = {**state, path: [*path, ".#{name}"]}
  30. schema =
  31. case type
  32. in: 0 in {"$ref": String}
  33. type
  34. in: 0 in OpenAI::Helpers::StructuredOutput::JsonSchemaConverter
  35. type.to_json_schema_inner(state: new_state).update(field.slice(:description))
  36. else: 0 else
  37. OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_json_schema_inner(
  38. type,
  39. state: new_state
  40. )
  41. end
  42. then: 0 else: 0 schema = OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_nilable(schema) if nilable
  43. [name, schema]
  44. end
  45. {
  46. type: "object",
  47. properties: properties,
  48. required: properties.keys.map(&:to_s),
  49. additionalProperties: false
  50. }
  51. end
  52. end
  53. end
  54. 1 class << self
  55. 1 def required(name_sym, type_info, spec = {})
  56. super
  57. doc = [type_info, spec].grep(Hash).filter_map { _1[:doc] }.first
  58. else: 0 then: 0 known_fields.fetch(name_sym).update(description: doc) unless doc.nil?
  59. end
  60. 1 def optional(...)
  61. # rubocop:disable Layout/LineLength
  62. message = "`optional` is not supported for structured output APIs, use `#required` with `nil?: true` instead"
  63. # rubocop:enable Layout/LineLength
  64. raise RuntimeError.new(message)
  65. end
  66. end
  67. end
  68. end
  69. end
  70. end

openai-ruby/lib/openai/helpers/structured_output/boolean.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Helpers
  4. 1 module StructuredOutput
  5. # @abstract
  6. #
  7. # Ruby does not have a "boolean" Class, this is something for models to refer to.
  8. 1 class Boolean < OpenAI::Internal::Type::Boolean
  9. 1 extend OpenAI::Helpers::StructuredOutput::JsonSchemaConverter
  10. # rubocop:disable Lint/UnusedMethodArgument
  11. # @api private
  12. #
  13. # @param state [Hash{Symbol=>Object}]
  14. #
  15. # @option state [Hash{Object=>String}] :defs
  16. #
  17. # @option state [Array<String>] :path
  18. #
  19. # @return [Hash{Symbol=>Object}]
  20. 1 def self.to_json_schema_inner(state:) = {type: "boolean"}
  21. # rubocop:enable Lint/UnusedMethodArgument
  22. end
  23. end
  24. end
  25. end

openai-ruby/lib/openai/helpers/structured_output/enum_of.rb

52.38% lines covered

0.0% branches covered

21 relevant lines. 11 lines covered and 10 lines missed.
12 total branches, 0 branches covered and 12 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Helpers
  4. 1 module StructuredOutput
  5. # @generic Value
  6. #
  7. # @example
  8. # example = OpenAI::EnumOf[:foo, :bar, :zoo]
  9. #
  10. # @example
  11. # example = OpenAI::EnumOf[1, 2, 3]
  12. 1 class EnumOf
  13. 1 include OpenAI::Internal::Type::Enum
  14. 1 include OpenAI::Helpers::StructuredOutput::JsonSchemaConverter
  15. # @api private
  16. #
  17. # @param state [Hash{Symbol=>Object}]
  18. #
  19. # @option state [Hash{Object=>String}] :defs
  20. #
  21. # @option state [Array<String>] :path
  22. #
  23. # @return [Hash{Symbol=>Object}]
  24. 1 def to_json_schema_inner(state:)
  25. OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.cache_def!(state, type: self) do
  26. types = values.map do
  27. else: 0 case _1
  28. in: 0 in NilClass
  29. "null"
  30. in: 0 in true | false
  31. "boolean"
  32. in: 0 in Integer
  33. "integer"
  34. in: 0 in Float
  35. "number"
  36. in: 0 in Symbol
  37. "string"
  38. end
  39. end
  40. .uniq
  41. {
  42. then: 0 else: 0 type: types.length == 1 ? types.first : types,
  43. then: 0 else: 0 enum: values.map { _1.is_a?(Symbol) ? _1.to_s : _1 }
  44. }
  45. end
  46. end
  47. 1 private_class_method :new
  48. 1 def self.[](...) = new(...)
  49. # @return [Array<generic<Value>>]
  50. 1 attr_reader :values
  51. # @param values [Array<generic<Value>>]
  52. 1 then: 0 else: 0 def initialize(*values) = (@values = values.map { _1.is_a?(String) ? _1.to_sym : _1 })
  53. end
  54. end
  55. end
  56. end

openai-ruby/lib/openai/helpers/structured_output/json_schema_converter.rb

21.21% lines covered

0.0% branches covered

66 relevant lines. 14 lines covered and 52 lines missed.
30 total branches, 0 branches covered and 30 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Helpers
  4. 1 module StructuredOutput
  5. # To customize the JSON schema conversion for a type, implement the `JsonSchemaConverter` interface.
  6. 1 module JsonSchemaConverter
  7. # @api private
  8. 1 POINTERS = Object.new.tap do
  9. 1 _1.define_singleton_method(:inspect) do
  10. "#<#{OpenAI::Helpers::StructuredOutput::JsonSchemaConverter}::POINTERS>"
  11. end
  12. end.freeze
  13. # @api private
  14. 1 NO_REF = Object.new.tap do
  15. 1 _1.define_singleton_method(:inspect) do
  16. "#<#{OpenAI::Helpers::StructuredOutput::JsonSchemaConverter}::NO_REF>"
  17. end
  18. end.freeze
  19. # rubocop:disable Lint/UnusedMethodArgument
  20. # The exact JSON schema produced is subject to improvement between minor release versions.
  21. #
  22. # @param state [Hash{Symbol=>Object}]
  23. #
  24. # @option state [Hash{Object=>String}] :defs
  25. #
  26. # @option state [Array<String>] :path
  27. #
  28. # @return [Hash{Symbol=>Object}]
  29. 1 def to_json_schema_inner(state:) = (raise NotImplementedError)
  30. # rubocop:enable Lint/UnusedMethodArgument
  31. # Internal helpers methods.
  32. 1 class << self
  33. # @api private
  34. #
  35. # @param schema [Hash{Symbol=>Object}]
  36. #
  37. # @return [Hash{Symbol=>Object}]
  38. 1 def to_nilable(schema)
  39. null = "null"
  40. else: 0 case schema
  41. in: 0 in {"$ref": String}
  42. {
  43. anyOf: [
  44. schema.update(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::NO_REF => true),
  45. {type: null}
  46. ]
  47. }
  48. in: 0 in {anyOf: schemas}
  49. null = {type: null}
  50. then: 0 else: 0 schemas.any? { _1 == null || _1 == {type: ["null"]} } ? schema : {anyOf: [*schemas, null]}
  51. in: 0 in {type: String => type}
  52. then: 0 else: 0 type == null ? schema : schema.update(type: [type, null])
  53. in: 0 in {type: Array => types}
  54. then: 0 else: 0 types.include?(null) ? schema : schema.update(type: [*types, null])
  55. end
  56. end
  57. # @api private
  58. #
  59. # @param state [Hash{Symbol=>Object}]
  60. #
  61. # @option state [Hash{Object=>String}] :defs
  62. #
  63. # @option state [Array<String>] :path
  64. #
  65. # @param type [Object]
  66. #
  67. # @param blk [Proc]
  68. #
  69. 1 def cache_def!(state, type:, &blk)
  70. defs, path = state.fetch_values(:defs, :path)
  71. then: 0 if (stored = defs[type])
  72. pointers = stored.fetch(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::POINTERS)
  73. pointers.first.except(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::NO_REF).tap do
  74. pointers << _1
  75. end
  76. else: 0 else
  77. ref_path = String.new
  78. ref = {"$ref": ref_path}
  79. stored = {
  80. OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::POINTERS => [ref]
  81. }
  82. defs.store(type, stored)
  83. schema = blk.call
  84. ref_path.replace("#/$defs/#{path.join('/')}")
  85. stored.update(schema)
  86. ref
  87. end
  88. end
  89. # @api private
  90. #
  91. # @param type [OpenAI::Helpers::StructuredOutput::JsonSchemaConverter, Class]
  92. #
  93. # @return [Hash{Symbol=>Object}]
  94. 1 def to_json_schema(type)
  95. defs = {}
  96. state = {defs: defs, path: []}
  97. schema = OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_json_schema_inner(
  98. type,
  99. state: state
  100. )
  101. reused_defs = {}
  102. defs.each_value do |acc|
  103. sch = acc.except(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::POINTERS)
  104. pointers = acc.fetch(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::POINTERS)
  105. no_refs, refs = pointers.partition do
  106. _1.delete(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::NO_REF)
  107. end
  108. case refs
  109. in: 0 in [ref]
  110. ref.replace(sch)
  111. in: 0 in [_, ref, *]
  112. else: 0 reused_defs.store(ref.fetch(:$ref), sch)
  113. else
  114. end
  115. no_refs.each { _1.replace(sch) }
  116. end
  117. xformed = reused_defs.transform_keys { _1.delete_prefix("#/$defs/") }
  118. then: 0 else: 0 xformed.empty? ? schema : {"$defs": xformed}.update(schema)
  119. end
  120. # @api private
  121. #
  122. # @param type [OpenAI::Helpers::StructuredOutput::JsonSchemaConverter, Class]
  123. #
  124. # @param state [Hash{Symbol=>Object}]
  125. #
  126. # @option state [Hash{Object=>String}] :defs
  127. #
  128. # @option state [Array<String>] :path
  129. #
  130. # @return [Hash{Symbol=>Object}]
  131. 1 def to_json_schema_inner(type, state:)
  132. case type
  133. in: 0 in {"$ref": String}
  134. return type
  135. in: 0 in OpenAI::Helpers::StructuredOutput::JsonSchemaConverter
  136. return type.to_json_schema_inner(state: state)
  137. in: 0 in Class
  138. case type
  139. in: 0 in -> { _1 <= NilClass }
  140. return {type: "null"}
  141. in: 0 in -> { _1 <= Integer }
  142. return {type: "integer"}
  143. in: 0 in -> { _1 <= Float }
  144. return {type: "number"}
  145. in: 0 in -> { _1 <= Symbol || _1 <= String }
  146. else: 0 return {type: "string"}
  147. else
  148. end
  149. in: 0 in _ if OpenAI::Internal::Util.primitive?(type)
  150. else: 0 then: 0 else: 0 return {const: type.is_a?(Symbol) ? type.to_s : type}
  151. else
  152. end
  153. models = %w[
  154. NilClass
  155. String
  156. Symbol
  157. Integer
  158. Float
  159. OpenAI::Boolean
  160. OpenAI::ArrayOf
  161. OpenAI::EnumOf
  162. OpenAI::UnionOf
  163. OpenAI::BaseModel
  164. ]
  165. # rubocop:disable Layout/LineLength
  166. message = "#{type} does not implement the #{OpenAI::Helpers::StructuredOutput::JsonSchemaConverter} interface. Please use one of the supported types: #{models}"
  167. # rubocop:enable Layout/LineLength
  168. raise ArgumentError.new(message)
  169. end
  170. end
  171. end
  172. end
  173. end
  174. end

openai-ruby/lib/openai/helpers/structured_output/parsed_json.rb

75.0% lines covered

0.0% branches covered

8 relevant lines. 6 lines covered and 2 lines missed.
2 total branches, 0 branches covered and 2 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Helpers
  4. 1 module StructuredOutput
  5. # @abstract
  6. #
  7. # Like OpenAI::Internal::Type::Unknown, but for parsed JSON values, which can be incomplete or malformed.
  8. 1 class ParsedJson < OpenAI::Internal::Type::Unknown
  9. 1 class << self
  10. # @api private
  11. #
  12. # No coercion needed for Unknown type.
  13. #
  14. # @param value [Object]
  15. #
  16. # @param state [Hash{Symbol=>Object}] .
  17. #
  18. # @option state [Boolean] :translate_names
  19. #
  20. # @option state [Boolean] :strictness
  21. #
  22. # @option state [Hash{Symbol=>Object}] :exactness
  23. #
  24. # @option state [Class<StandardError>] :error
  25. #
  26. # @option state [Integer] :branched
  27. #
  28. # @return [Object]
  29. 1 def coerce(value, state:)
  30. then: 0 else: 0 (state[:error] = value) if value.is_a?(StandardError)
  31. super
  32. end
  33. end
  34. end
  35. end
  36. end
  37. end

openai-ruby/lib/openai/helpers/structured_output/union_of.rb

43.33% lines covered

16.67% branches covered

30 relevant lines. 13 lines covered and 17 lines missed.
12 total branches, 2 branches covered and 10 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Helpers
  4. 1 module StructuredOutput
  5. # @generic Member
  6. #
  7. # @example
  8. # example = OpenAI::UnionOf[Float, OpenAI::ArrayOf[Integer]]
  9. 1 class UnionOf
  10. 1 include OpenAI::Internal::Type::Union
  11. 1 include OpenAI::Helpers::StructuredOutput::JsonSchemaConverter
  12. # @api private
  13. #
  14. # @param state [Hash{Symbol=>Object}]
  15. #
  16. # @option state [Hash{Object=>String}] :defs
  17. #
  18. # @option state [Array<String>] :path
  19. #
  20. # @return [Hash{Symbol=>Object}]
  21. 1 def to_json_schema_inner(state:)
  22. OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.cache_def!(state, type: self) do
  23. path = state.fetch(:path)
  24. mergeable_keys = {[:anyOf] => 0, [:type] => 0}
  25. schemas = variants.to_enum.with_index.map do
  26. new_state = {**state, path: [*path, "?.#{_2}"]}
  27. OpenAI::Helpers::StructuredOutput::JsonSchemaConverter.to_json_schema_inner(
  28. _1,
  29. state: new_state
  30. )
  31. end
  32. schemas.each do |schema|
  33. then: 0 else: 0 mergeable_keys.each_key { mergeable_keys[_1] += 1 if schema.keys == _1 }
  34. end
  35. mergeable = mergeable_keys.any? { _1.last == schemas.length }
  36. then: 0 if mergeable
  37. OpenAI::Internal::Util.deep_merge(*schemas, concat: true)
  38. else: 0 else
  39. {
  40. anyOf: schemas.each do
  41. then: 0 else: 0 if _1.key?(:$ref)
  42. _1.update(OpenAI::Helpers::StructuredOutput::JsonSchemaConverter::NO_REF => true)
  43. end
  44. end
  45. }
  46. end
  47. end
  48. end
  49. 1 private_class_method :new
  50. 1 def self.[](...) = new(...)
  51. # @param variants [Array<generic<Member>>]
  52. 1 def initialize(*variants)
  53. case variants
  54. 3 in: 0 in [Symbol => d, Hash => vs]
  55. discriminator(d)
  56. vs.each do |k, v|
  57. then: 0 else: 0 v.is_a?(Proc) ? variant(k, v) : variant(k, -> { v })
  58. end
  59. else: 3 else
  60. 3 variants.each do |v|
  61. 10 then: 0 else: 6 v.is_a?(Proc) ? variant(v) : variant(-> { v })
  62. end
  63. end
  64. end
  65. end
  66. end
  67. end
  68. end

openai-ruby/lib/openai/internal.rb

77.78% lines covered

100.0% branches covered

9 relevant lines. 7 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 extend OpenAI::Internal::Util::SorbetRuntimeSupport
  5. OMIT =
  6. 1 Object.new.tap do
  7. 1 _1.define_singleton_method(:inspect) { "#<#{OpenAI::Internal}::OMIT>" }
  8. end
  9. .freeze
  10. 1 define_sorbet_constant!(:AnyHash) do
  11. T.type_alias { T::Hash[Symbol, T.anything] }
  12. end
  13. 1 define_sorbet_constant!(:FileInput) do
  14. T.type_alias { T.any(Pathname, StringIO, IO, String, OpenAI::FilePart) }
  15. end
  16. end
  17. end

openai-ruby/lib/openai/internal/cursor_page.rb

36.67% lines covered

0.0% branches covered

30 relevant lines. 11 lines covered and 19 lines missed.
14 total branches, 0 branches covered and 14 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. # @generic Elem
  5. #
  6. # @example
  7. # if cursor_page.has_next?
  8. # cursor_page = cursor_page.next_page
  9. # end
  10. #
  11. # @example
  12. # cursor_page.auto_paging_each do |completion|
  13. # puts(completion)
  14. # end
  15. 1 class CursorPage
  16. 1 include OpenAI::Internal::Type::BasePage
  17. # @return [Array<generic<Elem>>, nil]
  18. 1 attr_accessor :data
  19. # @return [Boolean]
  20. 1 attr_accessor :has_more
  21. # @return [Boolean]
  22. 1 def next_page?
  23. has_more
  24. end
  25. # @raise [OpenAI::HTTP::Error]
  26. # @return [self]
  27. 1 def next_page
  28. else: 0 then: 0 unless next_page?
  29. message = "No more pages available. Please check #next_page? before calling ##{__method__}"
  30. raise RuntimeError.new(message)
  31. end
  32. then: 0 else: 0 then: 0 else: 0 req = OpenAI::Internal::Util.deep_merge(@req, {query: {after: data&.last&.id}})
  33. @client.request(req)
  34. end
  35. # @param blk [Proc]
  36. #
  37. # @yieldparam [generic<Elem>]
  38. 1 def auto_paging_each(&blk)
  39. else: 0 then: 0 unless block_given?
  40. raise ArgumentError.new("A block must be given to ##{__method__}")
  41. end
  42. page = self
  43. loop do
  44. then: 0 else: 0 page.data&.each(&blk)
  45. else: 0 then: 0 break unless page.next_page?
  46. page = page.next_page
  47. end
  48. end
  49. # @api private
  50. #
  51. # @param client [OpenAI::Internal::Transport::BaseClient]
  52. # @param req [Hash{Symbol=>Object}]
  53. # @param headers [Hash{String=>String}, Net::HTTPHeader]
  54. # @param page_data [Hash{Symbol=>Object}]
  55. 1 def initialize(client:, req:, headers:, page_data:)
  56. super
  57. case page_data
  58. in: 0 in {data: Array => data}
  59. else: 0 @data = data.map { OpenAI::Internal::Type::Converter.coerce(@model, _1) }
  60. else
  61. end
  62. @has_more = page_data[:has_more]
  63. end
  64. # @api private
  65. #
  66. # @return [String]
  67. 1 def inspect
  68. model = OpenAI::Internal::Type::Converter.inspect(@model, depth: 1)
  69. "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)} has_more=#{has_more.inspect}>"
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/internal/page.rb

42.31% lines covered

0.0% branches covered

26 relevant lines. 11 lines covered and 15 lines missed.
8 total branches, 0 branches covered and 8 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. # @generic Elem
  5. #
  6. # @example
  7. # if page.has_next?
  8. # page = page.next_page
  9. # end
  10. #
  11. # @example
  12. # page.auto_paging_each do |model|
  13. # puts(model)
  14. # end
  15. 1 class Page
  16. 1 include OpenAI::Internal::Type::BasePage
  17. # @return [Array<generic<Elem>>, nil]
  18. 1 attr_accessor :data
  19. # @return [String]
  20. 1 attr_accessor :object
  21. # @return [Boolean]
  22. 1 def next_page?
  23. false
  24. end
  25. # @raise [OpenAI::HTTP::Error]
  26. # @return [self]
  27. 1 def next_page
  28. RuntimeError.new("No more pages available.")
  29. end
  30. # @param blk [Proc]
  31. #
  32. # @yieldparam [generic<Elem>]
  33. 1 def auto_paging_each(&blk)
  34. else: 0 then: 0 unless block_given?
  35. raise ArgumentError.new("A block must be given to ##{__method__}")
  36. end
  37. page = self
  38. loop do
  39. then: 0 else: 0 page.data&.each(&blk)
  40. else: 0 then: 0 break unless page.next_page?
  41. page = page.next_page
  42. end
  43. end
  44. # @api private
  45. #
  46. # @param client [OpenAI::Internal::Transport::BaseClient]
  47. # @param req [Hash{Symbol=>Object}]
  48. # @param headers [Hash{String=>String}, Net::HTTPHeader]
  49. # @param page_data [Array<Object>]
  50. 1 def initialize(client:, req:, headers:, page_data:)
  51. super
  52. case page_data
  53. in: 0 in {data: Array => data}
  54. else: 0 @data = data.map { OpenAI::Internal::Type::Converter.coerce(@model, _1) }
  55. else
  56. end
  57. @object = page_data[:object]
  58. end
  59. # @api private
  60. #
  61. # @return [String]
  62. 1 def inspect
  63. model = OpenAI::Internal::Type::Converter.inspect(@model, depth: 1)
  64. "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)} object=#{object.inspect}>"
  65. end
  66. end
  67. end
  68. end

openai-ruby/lib/openai/internal/stream.rb

25.0% lines covered

0.0% branches covered

20 relevant lines. 5 lines covered and 15 lines missed.
11 total branches, 0 branches covered and 11 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. # @generic Elem
  5. #
  6. # @example
  7. # stream.each do |event|
  8. # puts(event)
  9. # end
  10. 1 class Stream
  11. 1 include OpenAI::Internal::Type::BaseStream
  12. # @api private
  13. #
  14. # @return [Enumerable<generic<Elem>>]
  15. 1 private def iterator
  16. # rubocop:disable Metrics/BlockLength
  17. @iterator ||= OpenAI::Internal::Util.chain_fused(@stream) do |y|
  18. consume = false
  19. @stream.each do |msg|
  20. then: 0 else: 0 next if consume
  21. case msg
  22. in: 0 in {data: String => data} if data.start_with?("[DONE]")
  23. consume = true
  24. next
  25. in: 0 in {data: String => data}
  26. else: 0 case JSON.parse(data, symbolize_names: true)
  27. in: 0 in {error: error}
  28. message =
  29. case error
  30. in: 0 in String
  31. error
  32. in: 0 in {message: String => m}
  33. m
  34. else: 0 else
  35. "An error occurred during streaming"
  36. end
  37. OpenAI::Errors::APIError.for(
  38. url: @url,
  39. status: @status,
  40. body: body,
  41. request: nil,
  42. response: @response,
  43. message: message
  44. )
  45. in: 0 in decoded
  46. unwrapped = OpenAI::Internal::Util.dig(decoded, @unwrap)
  47. y << OpenAI::Internal::Type::Converter.coerce(@model, unwrapped)
  48. else: 0 end
  49. else
  50. end
  51. end
  52. end
  53. # rubocop:enable Metrics/BlockLength
  54. end
  55. end
  56. end
  57. end

openai-ruby/lib/openai/internal/transport/base_client.rb

58.04% lines covered

24.07% branches covered

143 relevant lines. 83 lines covered and 60 lines missed.
54 total branches, 13 branches covered and 41 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Transport
  5. # @api private
  6. #
  7. # @abstract
  8. 1 class BaseClient
  9. 1 extend OpenAI::Internal::Util::SorbetRuntimeSupport
  10. # from whatwg fetch spec
  11. 1 MAX_REDIRECTS = 20
  12. # rubocop:disable Style/MutableConstant
  13. PLATFORM_HEADERS =
  14. {
  15. 1 "x-stainless-arch" => OpenAI::Internal::Util.arch,
  16. "x-stainless-lang" => "ruby",
  17. "x-stainless-os" => OpenAI::Internal::Util.os,
  18. "x-stainless-package-version" => OpenAI::VERSION,
  19. "x-stainless-runtime" => ::RUBY_ENGINE,
  20. "x-stainless-runtime-version" => ::RUBY_ENGINE_VERSION
  21. }
  22. # rubocop:enable Style/MutableConstant
  23. 1 class << self
  24. # @api private
  25. #
  26. # @param req [Hash{Symbol=>Object}]
  27. #
  28. # @raise [ArgumentError]
  29. 1 def validate!(req)
  30. 2 keys = [:method, :path, :query, :headers, :body, :unwrap, :page, :stream, :model, :options]
  31. case req
  32. 2 in: 2 in Hash
  33. 2 req.each_key do |k|
  34. 12 else: 12 then: 0 unless keys.include?(k)
  35. raise ArgumentError.new("Request `req` keys must be one of #{keys}, got #{k.inspect}")
  36. end
  37. end
  38. else: 0 else
  39. raise ArgumentError.new("Request `req` must be a Hash or RequestOptions, got #{req.inspect}")
  40. end
  41. end
  42. # @api private
  43. #
  44. # @param status [Integer]
  45. # @param headers [Hash{String=>String}, Net::HTTPHeader]
  46. #
  47. # @return [Boolean]
  48. 1 def should_retry?(status, headers:)
  49. 2 coerced = OpenAI::Internal::Util.coerce_boolean(headers["x-should-retry"])
  50. case [coerced, status]
  51. 2 in: 0 in [true | false, _]
  52. coerced
  53. in [_, 408 | 409 | 429 | (500..)]
  54. # retry on:
  55. # 408: timeouts
  56. # 409: locks
  57. # 429: rate limits
  58. in: 0 # 500+: unknown errors
  59. true
  60. else: 2 else
  61. 2 false
  62. end
  63. end
  64. # @api private
  65. #
  66. # @param request [Hash{Symbol=>Object}] .
  67. #
  68. # @option request [Symbol] :method
  69. #
  70. # @option request [URI::Generic] :url
  71. #
  72. # @option request [Hash{String=>String}] :headers
  73. #
  74. # @option request [Object] :body
  75. #
  76. # @option request [Integer] :max_retries
  77. #
  78. # @option request [Float] :timeout
  79. #
  80. # @param status [Integer]
  81. #
  82. # @param response_headers [Hash{String=>String}, Net::HTTPHeader]
  83. #
  84. # @return [Hash{Symbol=>Object}]
  85. 1 def follow_redirect(request, status:, response_headers:)
  86. method, url, headers = request.fetch_values(:method, :url, :headers)
  87. location =
  88. Kernel.then do
  89. URI.join(url, response_headers["location"])
  90. rescue ArgumentError
  91. message = "Server responded with status #{status} but no valid location header."
  92. raise OpenAI::Errors::APIConnectionError.new(
  93. url: url,
  94. response: response_headers,
  95. message: message
  96. )
  97. end
  98. request = {**request, url: location}
  99. case [url.scheme, location.scheme]
  100. in: 0 in ["https", "http"]
  101. message = "Tried to redirect to a insecure URL"
  102. raise OpenAI::Errors::APIConnectionError.new(
  103. url: url,
  104. response: response_headers,
  105. message: message
  106. )
  107. else: 0 else
  108. nil
  109. end
  110. # from whatwg fetch spec
  111. case [status, method]
  112. in: 0 in [301 | 302, :post] | [303, _]
  113. drop = %w[content-encoding content-language content-length content-location content-type]
  114. request = {
  115. **request,
  116. then: 0 else: 0 method: method == :head ? :head : :get,
  117. headers: headers.except(*drop),
  118. body: nil
  119. else: 0 }
  120. else
  121. end
  122. # from undici
  123. then: 0 else: 0 if OpenAI::Internal::Util.uri_origin(url) != OpenAI::Internal::Util.uri_origin(location)
  124. drop = %w[authorization cookie host proxy-authorization]
  125. request = {**request, headers: request.fetch(:headers).except(*drop)}
  126. end
  127. request
  128. end
  129. # @api private
  130. #
  131. # @param status [Integer, OpenAI::Errors::APIConnectionError]
  132. # @param stream [Enumerable<String>, nil]
  133. 1 def reap_connection!(status, stream:)
  134. case status
  135. 2 in: 2 in (..199) | (300..499)
  136. 2 then: 2 else: 0 stream&.each { next }
  137. in: 0 in OpenAI::Errors::APIConnectionError | (500..)
  138. else: 0 OpenAI::Internal::Util.close_fused!(stream)
  139. else
  140. end
  141. end
  142. end
  143. # @return [URI::Generic]
  144. 1 attr_reader :base_url
  145. # @return [Float]
  146. 1 attr_reader :timeout
  147. # @return [Integer]
  148. 1 attr_reader :max_retries
  149. # @return [Float]
  150. 1 attr_reader :initial_retry_delay
  151. # @return [Float]
  152. 1 attr_reader :max_retry_delay
  153. # @return [Hash{String=>String}]
  154. 1 attr_reader :headers
  155. # @return [String, nil]
  156. 1 attr_reader :idempotency_header
  157. # @api private
  158. # @return [OpenAI::Internal::Transport::PooledNetRequester]
  159. 1 attr_reader :requester
  160. # @api private
  161. #
  162. # @param base_url [String]
  163. # @param timeout [Float]
  164. # @param max_retries [Integer]
  165. # @param initial_retry_delay [Float]
  166. # @param max_retry_delay [Float]
  167. # @param headers [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}]
  168. # @param idempotency_header [String, nil]
  169. 1 def initialize(
  170. base_url:,
  171. timeout: 0.0,
  172. max_retries: 0,
  173. initial_retry_delay: 0.0,
  174. max_retry_delay: 0.0,
  175. headers: {},
  176. idempotency_header: nil
  177. )
  178. 2 @requester = OpenAI::Internal::Transport::PooledNetRequester.new
  179. 2 @headers = OpenAI::Internal::Util.normalized_headers(
  180. self.class::PLATFORM_HEADERS,
  181. {
  182. "accept" => "application/json",
  183. "content-type" => "application/json"
  184. },
  185. headers
  186. )
  187. 2 @base_url_components = OpenAI::Internal::Util.parse_uri(base_url)
  188. 2 @base_url = OpenAI::Internal::Util.unparse_uri(@base_url_components)
  189. 2 then: 0 else: 2 then: 0 else: 2 @idempotency_header = idempotency_header&.to_s&.downcase
  190. 2 @timeout = timeout
  191. 2 @max_retries = max_retries
  192. 2 @initial_retry_delay = initial_retry_delay
  193. 2 @max_retry_delay = max_retry_delay
  194. end
  195. # @api private
  196. #
  197. # @return [Hash{String=>String}]
  198. 1 private def auth_headers = {}
  199. # @api private
  200. #
  201. # @return [String]
  202. 1 private def generate_idempotency_key = "stainless-ruby-retry-#{SecureRandom.uuid}"
  203. # @api private
  204. #
  205. # @param req [Hash{Symbol=>Object}] .
  206. #
  207. # @option req [Symbol] :method
  208. #
  209. # @option req [String, Array<String>] :path
  210. #
  211. # @option req [Hash{String=>Array<String>, String, nil}, nil] :query
  212. #
  213. # @option req [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}, nil] :headers
  214. #
  215. # @option req [Object, nil] :body
  216. #
  217. # @option req [Symbol, Integer, Array<Symbol, Integer>, Proc, nil] :unwrap
  218. #
  219. # @option req [Class<OpenAI::Internal::Type::BasePage>, nil] :page
  220. #
  221. # @option req [Class<OpenAI::Internal::Type::BaseStream>, nil] :stream
  222. #
  223. # @option req [OpenAI::Internal::Type::Converter, Class, nil] :model
  224. #
  225. # @param opts [Hash{Symbol=>Object}] .
  226. #
  227. # @option opts [String, nil] :idempotency_key
  228. #
  229. # @option opts [Hash{String=>Array<String>, String, nil}, nil] :extra_query
  230. #
  231. # @option opts [Hash{String=>String, nil}, nil] :extra_headers
  232. #
  233. # @option opts [Object, nil] :extra_body
  234. #
  235. # @option opts [Integer, nil] :max_retries
  236. #
  237. # @option opts [Float, nil] :timeout
  238. #
  239. # @return [Hash{Symbol=>Object}]
  240. 1 private def build_request(req, opts)
  241. 2 method, uninterpolated_path = req.fetch_values(:method, :path)
  242. 2 path = OpenAI::Internal::Util.interpolate_path(uninterpolated_path)
  243. 2 query = OpenAI::Internal::Util.deep_merge(req[:query].to_h, opts[:extra_query].to_h)
  244. 2 headers = OpenAI::Internal::Util.normalized_headers(
  245. @headers,
  246. auth_headers,
  247. req[:headers].to_h,
  248. opts[:extra_headers].to_h
  249. )
  250. 2 else: 2 if @idempotency_header &&
  251. !headers.key?(@idempotency_header) &&
  252. then: 0 (!Net::HTTP::IDEMPOTENT_METHODS_.include?(method.to_s.upcase) || opts.key?(:idempotency_key))
  253. headers[@idempotency_header] = opts.fetch(:idempotency_key) { generate_idempotency_key }
  254. end
  255. 2 else: 0 then: 2 unless headers.key?("x-stainless-retry-count")
  256. 2 headers["x-stainless-retry-count"] = "0"
  257. end
  258. 2 timeout = opts.fetch(:timeout, @timeout).to_f.clamp(0..)
  259. 2 else: 0 then: 2 unless headers.key?("x-stainless-timeout") || timeout.zero?
  260. 2 headers["x-stainless-timeout"] = timeout.to_s
  261. end
  262. 28 headers.reject! { |_, v| v.to_s.empty? }
  263. body =
  264. case method
  265. 2 in: 0 in :get | :head | :options | :trace
  266. nil
  267. else: 2 else
  268. 2 OpenAI::Internal::Util.deep_merge(*[req[:body], opts[:extra_body]].compact)
  269. end
  270. 2 url = OpenAI::Internal::Util.join_parsed_uri(
  271. @base_url_components,
  272. {**req, path: path, query: query}
  273. )
  274. 2 headers, encoded = OpenAI::Internal::Util.encode_content(headers, body)
  275. {
  276. 2 method: method,
  277. url: url,
  278. headers: headers,
  279. body: encoded,
  280. max_retries: opts.fetch(:max_retries, @max_retries),
  281. timeout: timeout
  282. }
  283. end
  284. # @api private
  285. #
  286. # @param headers [Hash{String=>String}]
  287. # @param retry_count [Integer]
  288. #
  289. # @return [Float]
  290. 1 private def retry_delay(headers, retry_count:)
  291. # Non-standard extension
  292. then: 0 else: 0 span = Float(headers["retry-after-ms"], exception: false)&.then { _1 / 1000 }
  293. then: 0 else: 0 return span if span
  294. retry_header = headers["retry-after"]
  295. then: 0 else: 0 return span if (span = Float(retry_header, exception: false))
  296. then: 0 else: 0 span = retry_header&.then do
  297. Time.httpdate(_1) - Time.now
  298. rescue ArgumentError
  299. nil
  300. end
  301. then: 0 else: 0 return span if span
  302. scale = retry_count**2
  303. jitter = 1 - (0.25 * rand)
  304. (@initial_retry_delay * scale * jitter).clamp(0, @max_retry_delay)
  305. end
  306. # @api private
  307. #
  308. # @param request [Hash{Symbol=>Object}] .
  309. #
  310. # @option request [Symbol] :method
  311. #
  312. # @option request [URI::Generic] :url
  313. #
  314. # @option request [Hash{String=>String}] :headers
  315. #
  316. # @option request [Object] :body
  317. #
  318. # @option request [Integer] :max_retries
  319. #
  320. # @option request [Float] :timeout
  321. #
  322. # @param redirect_count [Integer]
  323. #
  324. # @param retry_count [Integer]
  325. #
  326. # @param send_retry_header [Boolean]
  327. #
  328. # @raise [OpenAI::Errors::APIError]
  329. # @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
  330. 1 private def send_request(request, redirect_count:, retry_count:, send_retry_header:)
  331. 2 url, headers, max_retries, timeout = request.fetch_values(:url, :headers, :max_retries, :timeout)
  332. 2 input = {**request.except(:timeout), deadline: OpenAI::Internal::Util.monotonic_secs + timeout}
  333. 2 then: 2 else: 0 if send_retry_header
  334. 2 headers["x-stainless-retry-count"] = retry_count.to_s
  335. end
  336. begin
  337. 2 status, response, stream = @requester.execute(input)
  338. rescue OpenAI::Errors::APIConnectionError => e
  339. status = e
  340. end
  341. else: 0 case status
  342. 2 in: 0 in ..299
  343. [status, response, stream]
  344. in: 0 in 300..399 if redirect_count >= self.class::MAX_REDIRECTS
  345. self.class.reap_connection!(status, stream: stream)
  346. message = "Failed to complete the request within #{self.class::MAX_REDIRECTS} redirects."
  347. raise OpenAI::Errors::APIConnectionError.new(url: url, response: response, message: message)
  348. in: 0 in 300..399
  349. self.class.reap_connection!(status, stream: stream)
  350. request = self.class.follow_redirect(request, status: status, response_headers: response)
  351. send_request(
  352. request,
  353. redirect_count: redirect_count + 1,
  354. retry_count: retry_count,
  355. send_retry_header: send_retry_header
  356. )
  357. in: 0 in OpenAI::Errors::APIConnectionError if retry_count >= max_retries
  358. raise status
  359. in: 2 in (400..) if retry_count >= max_retries || !self.class.should_retry?(status, headers: response)
  360. 2 decoded = Kernel.then do
  361. 2 OpenAI::Internal::Util.decode_content(response, stream: stream, suppress_error: true)
  362. ensure
  363. 2 self.class.reap_connection!(status, stream: stream)
  364. end
  365. 2 raise OpenAI::Errors::APIStatusError.for(
  366. url: url,
  367. status: status,
  368. body: decoded,
  369. request: nil,
  370. response: response
  371. )
  372. in: 0 in (400..) | OpenAI::Errors::APIConnectionError
  373. self.class.reap_connection!(status, stream: stream)
  374. delay = retry_delay(response || {}, retry_count: retry_count)
  375. sleep(delay)
  376. send_request(
  377. request,
  378. redirect_count: redirect_count,
  379. retry_count: retry_count + 1,
  380. send_retry_header: send_retry_header
  381. )
  382. end
  383. end
  384. # Execute the request specified by `req`. This is the method that all resource
  385. # methods call into.
  386. #
  387. # @overload request(method, path, query: {}, headers: {}, body: nil, unwrap: nil, page: nil, stream: nil, model: OpenAI::Internal::Type::Unknown, options: {})
  388. #
  389. # @param method [Symbol]
  390. #
  391. # @param path [String, Array<String>]
  392. #
  393. # @param query [Hash{String=>Array<String>, String, nil}, nil]
  394. #
  395. # @param headers [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}, nil]
  396. #
  397. # @param body [Object, nil]
  398. #
  399. # @param unwrap [Symbol, Integer, Array<Symbol, Integer>, Proc, nil]
  400. #
  401. # @param page [Class<OpenAI::Internal::Type::BasePage>, nil]
  402. #
  403. # @param stream [Class<OpenAI::Internal::Type::BaseStream>, nil]
  404. #
  405. # @param model [OpenAI::Internal::Type::Converter, Class, nil]
  406. #
  407. # @param options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil] .
  408. #
  409. # @option options [String, nil] :idempotency_key
  410. #
  411. # @option options [Hash{String=>Array<String>, String, nil}, nil] :extra_query
  412. #
  413. # @option options [Hash{String=>String, nil}, nil] :extra_headers
  414. #
  415. # @option options [Object, nil] :extra_body
  416. #
  417. # @option options [Integer, nil] :max_retries
  418. #
  419. # @option options [Float, nil] :timeout
  420. #
  421. # @raise [OpenAI::Errors::APIError]
  422. # @return [Object]
  423. 1 def request(req)
  424. 2 self.class.validate!(req)
  425. 2 model = req.fetch(:model) { OpenAI::Internal::Type::Unknown }
  426. 2 opts = req[:options].to_h
  427. 2 unwrap = req[:unwrap]
  428. 2 OpenAI::RequestOptions.validate!(opts)
  429. 2 request = build_request(req.except(:options), opts)
  430. 2 url = request.fetch(:url)
  431. # Don't send the current retry count in the headers if the caller modified the header defaults.
  432. 2 send_retry_header = request.fetch(:headers)["x-stainless-retry-count"] == "0"
  433. 2 status, response, stream = send_request(
  434. request,
  435. redirect_count: 0,
  436. retry_count: 0,
  437. send_retry_header: send_retry_header
  438. )
  439. decoded = OpenAI::Internal::Util.decode_content(response, stream: stream)
  440. case req
  441. in: 0 in {stream: Class => st}
  442. st.new(
  443. model: model,
  444. url: url,
  445. status: status,
  446. response: response,
  447. unwrap: unwrap,
  448. stream: decoded
  449. )
  450. in: 0 in {page: Class => page}
  451. page.new(client: self, req: req, headers: response, page_data: decoded)
  452. else: 0 else
  453. unwrapped = OpenAI::Internal::Util.dig(decoded, unwrap)
  454. OpenAI::Internal::Type::Converter.coerce(model, unwrapped)
  455. end
  456. end
  457. # @api private
  458. #
  459. # @return [String]
  460. 1 def inspect
  461. # rubocop:disable Layout/LineLength
  462. "#<#{self.class.name}:0x#{object_id.to_s(16)} base_url=#{@base_url} max_retries=#{@max_retries} timeout=#{@timeout}>"
  463. # rubocop:enable Layout/LineLength
  464. end
  465. 1 define_sorbet_constant!(:RequestComponents) do
  466. T.type_alias do
  467. {
  468. method: Symbol,
  469. path: T.any(String, T::Array[String]),
  470. query: T.nilable(T::Hash[String, T.nilable(T.any(T::Array[String], String))]),
  471. headers: T.nilable(
  472. T::Hash[String,
  473. T.nilable(
  474. T.any(
  475. String,
  476. Integer,
  477. T::Array[T.nilable(T.any(String, Integer))]
  478. )
  479. )]
  480. ),
  481. body: T.nilable(T.anything),
  482. unwrap: T.nilable(
  483. T.any(
  484. Symbol,
  485. Integer,
  486. T::Array[T.any(Symbol, Integer)],
  487. T.proc.params(arg0: T.anything).returns(T.anything)
  488. )
  489. ),
  490. page: T.nilable(T::Class[OpenAI::Internal::Type::BasePage[OpenAI::Internal::Type::BaseModel]]),
  491. stream: T.nilable(
  492. T::Class[OpenAI::Internal::Type::BaseStream[T.anything,
  493. OpenAI::Internal::Type::BaseModel]]
  494. ),
  495. model: T.nilable(OpenAI::Internal::Type::Converter::Input),
  496. options: T.nilable(OpenAI::RequestOptions::OrHash)
  497. }
  498. end
  499. end
  500. 1 define_sorbet_constant!(:RequestInput) do
  501. T.type_alias do
  502. {
  503. method: Symbol,
  504. url: URI::Generic,
  505. headers: T::Hash[String, String],
  506. body: T.anything,
  507. max_retries: Integer,
  508. timeout: Float
  509. }
  510. end
  511. end
  512. end
  513. end
  514. end
  515. end

openai-ruby/lib/openai/internal/transport/pooled_net_requester.rb

87.5% lines covered

32.26% branches covered

80 relevant lines. 70 lines covered and 10 lines missed.
31 total branches, 10 branches covered and 21 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Transport
  5. # @api private
  6. 1 class PooledNetRequester
  7. 1 extend OpenAI::Internal::Util::SorbetRuntimeSupport
  8. # from the golang stdlib
  9. # https://github.com/golang/go/blob/c8eced8580028328fde7c03cbfcb720ce15b2358/src/net/http/transport.go#L49
  10. 1 KEEP_ALIVE_TIMEOUT = 30
  11. 1 DEFAULT_MAX_CONNECTIONS = [Etc.nprocessors, 99].max
  12. 1 class << self
  13. # @api private
  14. #
  15. # @param url [URI::Generic]
  16. #
  17. # @return [Net::HTTP]
  18. 1 def connect(url)
  19. port =
  20. else: 0 case [url.port, url.scheme]
  21. 2 in: 0 in [Integer, _]
  22. url.port
  23. in: 0 in [nil, "http" | "ws"]
  24. Net::HTTP.http_default_port
  25. in: 2 in [nil, "https" | "wss"]
  26. 2 Net::HTTP.https_default_port
  27. end
  28. 2 Net::HTTP.new(url.host, port).tap do
  29. 2 _1.use_ssl = %w[https wss].include?(url.scheme)
  30. 2 _1.max_retries = 0
  31. end
  32. end
  33. # @api private
  34. #
  35. # @param conn [Net::HTTP]
  36. # @param deadline [Float]
  37. 1 def calibrate_socket_timeout(conn, deadline)
  38. 10 timeout = deadline - OpenAI::Internal::Util.monotonic_secs
  39. 10 conn.open_timeout = conn.read_timeout = conn.write_timeout = conn.continue_timeout = timeout
  40. end
  41. # @api private
  42. #
  43. # @param request [Hash{Symbol=>Object}] .
  44. #
  45. # @option request [Symbol] :method
  46. #
  47. # @option request [URI::Generic] :url
  48. #
  49. # @option request [Hash{String=>String}] :headers
  50. #
  51. # @param blk [Proc]
  52. #
  53. # @yieldparam [String]
  54. # @return [Array(Net::HTTPGenericRequest, Proc)]
  55. 1 def build_request(request, &blk)
  56. 2 method, url, headers, body = request.fetch_values(:method, :url, :headers, :body)
  57. 2 req = Net::HTTPGenericRequest.new(
  58. method.to_s.upcase,
  59. !body.nil?,
  60. method != :head,
  61. URI(url.to_s) # ensure we construct a URI class of the right scheme
  62. )
  63. 24 headers.each { req[_1] = _2 }
  64. else: 0 case body
  65. 2 in: 0 in nil
  66. nil
  67. in: 2 in String
  68. 2 else: 0 then: 2 req["content-length"] ||= body.bytesize.to_s unless req["transfer-encoding"]
  69. 2 req.body_stream = OpenAI::Internal::Util::ReadIOAdapter.new(body, &blk)
  70. in: 0 in StringIO
  71. else: 0 then: 0 req["content-length"] ||= body.size.to_s unless req["transfer-encoding"]
  72. req.body_stream = OpenAI::Internal::Util::ReadIOAdapter.new(body, &blk)
  73. in: 0 in Pathname | IO | Enumerator
  74. else: 0 then: 0 req["transfer-encoding"] ||= "chunked" unless req["content-length"]
  75. req.body_stream = OpenAI::Internal::Util::ReadIOAdapter.new(body, &blk)
  76. end
  77. 2 then: 2 else: 0 [req, req.body_stream&.method(:close)]
  78. end
  79. end
  80. # @api private
  81. #
  82. # @param url [URI::Generic]
  83. # @param deadline [Float]
  84. # @param blk [Proc]
  85. #
  86. # @raise [Timeout::Error]
  87. # @yieldparam [Net::HTTP]
  88. 1 private def with_pool(url, deadline:, &blk)
  89. 2 origin = OpenAI::Internal::Util.uri_origin(url)
  90. 2 timeout = deadline - OpenAI::Internal::Util.monotonic_secs
  91. pool =
  92. 2 @mutex.synchronize do
  93. 2 @pools[origin] ||= ConnectionPool.new(size: @size) do
  94. 2 self.class.connect(url)
  95. end
  96. end
  97. 2 pool.with(timeout: timeout, &blk)
  98. end
  99. # @api private
  100. #
  101. # @param request [Hash{Symbol=>Object}] .
  102. #
  103. # @option request [Symbol] :method
  104. #
  105. # @option request [URI::Generic] :url
  106. #
  107. # @option request [Hash{String=>String}] :headers
  108. #
  109. # @option request [Object] :body
  110. #
  111. # @option request [Float] :deadline
  112. #
  113. # @return [Array(Integer, Net::HTTPResponse, Enumerable<String>)]
  114. 1 def execute(request)
  115. 2 url, deadline = request.fetch_values(:url, :deadline)
  116. 2 req = nil
  117. 2 eof = false
  118. 2 finished = false
  119. 2 closing = nil
  120. # rubocop:disable Metrics/BlockLength
  121. 2 enum = Enumerator.new do |y|
  122. 2 with_pool(url, deadline: deadline) do |conn|
  123. 2 then: 0 else: 2 next if finished
  124. 2 req, closing = self.class.build_request(request) do
  125. 4 self.class.calibrate_socket_timeout(conn, deadline)
  126. end
  127. 2 self.class.calibrate_socket_timeout(conn, deadline)
  128. 2 else: 0 then: 2 unless conn.started?
  129. 2 conn.keep_alive_timeout = self.class::KEEP_ALIVE_TIMEOUT
  130. 2 conn.start
  131. end
  132. 2 self.class.calibrate_socket_timeout(conn, deadline)
  133. 2 conn.request(req) do |rsp|
  134. 2 y << [conn, req, rsp]
  135. 2 then: 0 else: 2 break if finished
  136. 2 rsp.read_body do |bytes|
  137. 2 y << bytes.force_encoding(Encoding::BINARY)
  138. 2 then: 0 else: 2 break if finished
  139. 2 self.class.calibrate_socket_timeout(conn, deadline)
  140. end
  141. 2 eof = true
  142. end
  143. end
  144. rescue Timeout::Error
  145. raise OpenAI::Errors::APITimeoutError.new(url: url, request: req)
  146. rescue StandardError
  147. raise OpenAI::Errors::APIConnectionError.new(url: url, request: req)
  148. end
  149. # rubocop:enable Metrics/BlockLength
  150. 2 conn, _, response = enum.next
  151. 2 body = OpenAI::Internal::Util.fused_enum(enum, external: true) do
  152. 2 finished = true
  153. 2 tap do
  154. 2 enum.next
  155. rescue StopIteration
  156. 2 nil
  157. end
  158. ensure
  159. 2 then: 0 else: 0 then: 0 else: 2 conn.finish if !eof && conn&.started?
  160. 2 then: 2 else: 0 closing&.call
  161. end
  162. 2 [Integer(response.code), response, body]
  163. end
  164. # @api private
  165. #
  166. # @param size [Integer]
  167. 1 def initialize(size: self.class::DEFAULT_MAX_CONNECTIONS)
  168. 2 @mutex = Mutex.new
  169. 2 @size = size
  170. 2 @pools = {}
  171. end
  172. 1 define_sorbet_constant!(:Request) do
  173. T.type_alias do
  174. {
  175. method: Symbol,
  176. url: URI::Generic,
  177. headers: T::Hash[String, String],
  178. body: T.anything,
  179. deadline: Float
  180. }
  181. end
  182. end
  183. end
  184. end
  185. end
  186. end

openai-ruby/lib/openai/internal/type/array_of.rb

48.78% lines covered

0.0% branches covered

41 relevant lines. 20 lines covered and 21 lines missed.
8 total branches, 0 branches covered and 8 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. #
  7. # @abstract
  8. #
  9. # @generic Elem
  10. #
  11. # Array of items of a given type.
  12. 1 class ArrayOf
  13. 1 include OpenAI::Internal::Type::Converter
  14. 1 include OpenAI::Internal::Util::SorbetRuntimeSupport
  15. 1 private_class_method :new
  16. # @overload [](type_info, spec = {})
  17. #
  18. # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class]
  19. #
  20. # @param spec [Hash{Symbol=>Object}] .
  21. #
  22. # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
  23. #
  24. # @option spec [Proc] :enum
  25. #
  26. # @option spec [Proc] :union
  27. #
  28. # @option spec [Boolean] :"nil?"
  29. #
  30. # @return [self]
  31. 1 def self.[](...) = new(...)
  32. # @api public
  33. #
  34. # @param other [Object]
  35. #
  36. # @return [Boolean]
  37. 1 def ===(other) = other.is_a?(Array) && other.all?(item_type)
  38. # @api public
  39. #
  40. # @param other [Object]
  41. #
  42. # @return [Boolean]
  43. 1 def ==(other)
  44. # rubocop:disable Layout/LineLength
  45. other.is_a?(OpenAI::Internal::Type::ArrayOf) && other.nilable? == nilable? && other.item_type == item_type
  46. # rubocop:enable Layout/LineLength
  47. end
  48. # @api public
  49. #
  50. # @return [Integer]
  51. 1 def hash = [self.class, item_type].hash
  52. # @api private
  53. #
  54. # @param value [Array<Object>, Object]
  55. #
  56. # @param state [Hash{Symbol=>Object}] .
  57. #
  58. # @option state [Boolean] :translate_names
  59. #
  60. # @option state [Boolean] :strictness
  61. #
  62. # @option state [Hash{Symbol=>Object}] :exactness
  63. #
  64. # @option state [Class<StandardError>] :error
  65. #
  66. # @option state [Integer] :branched
  67. #
  68. # @return [Array<Object>, Object]
  69. 1 def coerce(value, state:)
  70. exactness = state.fetch(:exactness)
  71. else: 0 then: 0 unless value.is_a?(Array)
  72. exactness[:no] += 1
  73. state[:error] = TypeError.new("#{value.class} can't be coerced into #{Array}")
  74. return value
  75. end
  76. target = item_type
  77. exactness[:yes] += 1
  78. value
  79. .map do |item|
  80. case [nilable?, item]
  81. in: 0 in [true, nil]
  82. exactness[:yes] += 1
  83. nil
  84. else: 0 else
  85. OpenAI::Internal::Type::Converter.coerce(target, item, state: state)
  86. end
  87. end
  88. end
  89. # @api private
  90. #
  91. # @param value [Array<Object>, Object]
  92. #
  93. # @param state [Hash{Symbol=>Object}] .
  94. #
  95. # @option state [Boolean] :can_retry
  96. #
  97. # @return [Array<Object>, Object]
  98. 1 def dump(value, state:)
  99. target = item_type
  100. then: 0 if value.is_a?(Array)
  101. value.map do
  102. OpenAI::Internal::Type::Converter.dump(target, _1, state: state)
  103. end
  104. else: 0 else
  105. super
  106. end
  107. end
  108. # @api private
  109. #
  110. # @return [Object]
  111. 1 def to_sorbet_type
  112. T::Array[OpenAI::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)]
  113. end
  114. # @api private
  115. #
  116. # @return [generic<Elem>]
  117. 1 protected def item_type = @item_type_fn.call
  118. # @api private
  119. #
  120. # @return [Boolean]
  121. 1 protected def nilable? = @nilable
  122. # @api private
  123. #
  124. # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class]
  125. #
  126. # @param spec [Hash{Symbol=>Object}] .
  127. #
  128. # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
  129. #
  130. # @option spec [Proc] :enum
  131. #
  132. # @option spec [Proc] :union
  133. #
  134. # @option spec [Boolean] :"nil?"
  135. 1 def initialize(type_info, spec = {})
  136. 105 @item_type_fn = OpenAI::Internal::Type::Converter.type_info(type_info || spec)
  137. 105 @nilable = spec.fetch(:nil?, false)
  138. end
  139. # @api private
  140. #
  141. # @param depth [Integer]
  142. #
  143. # @return [String]
  144. 1 def inspect(depth: 0)
  145. items = OpenAI::Internal::Type::Converter.inspect(item_type, depth: depth.succ)
  146. then: 0 else: 0 "#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]"
  147. end
  148. end
  149. end
  150. end
  151. end

openai-ruby/lib/openai/internal/type/base_model.rb

38.37% lines covered

17.74% branches covered

172 relevant lines. 66 lines covered and 106 lines missed.
62 total branches, 11 branches covered and 51 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @abstract
  6. 1 class BaseModel
  7. 1 extend OpenAI::Internal::Type::Converter
  8. 1 extend OpenAI::Internal::Util::SorbetRuntimeSupport
  9. 1 class << self
  10. # @api private
  11. #
  12. # Assumes superclass fields are totally defined before fields are accessed /
  13. # defined on subclasses.
  14. #
  15. # @param child [Class<OpenAI::Internal::Type::BaseModel>]
  16. 1 def inherited(child)
  17. 809 super
  18. 809 child.known_fields.replace(known_fields.dup)
  19. end
  20. # @api private
  21. #
  22. # @return [Hash{Symbol=>Hash{Symbol=>Object}}]
  23. 1 def known_fields = @known_fields ||= {}
  24. # @api private
  25. #
  26. # @return [Hash{Symbol=>Hash{Symbol=>Object}}]
  27. 1 def fields
  28. known_fields.transform_values do |field|
  29. {**field.except(:type_fn), type: field.fetch(:type_fn).call}
  30. end
  31. end
  32. # @api private
  33. #
  34. # @param name_sym [Symbol]
  35. #
  36. # @param required [Boolean]
  37. #
  38. # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class]
  39. #
  40. # @param spec [Hash{Symbol=>Object}] .
  41. #
  42. # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
  43. #
  44. # @option spec [Proc] :enum
  45. #
  46. # @option spec [Proc] :union
  47. #
  48. # @option spec [Boolean] :"nil?"
  49. 1 private def add_field(name_sym, required:, type_info:, spec:)
  50. type_fn, info =
  51. else: 0 case type_info
  52. 2923 in: 2164 in Proc | OpenAI::Internal::Type::Converter | Class
  53. 2164 [OpenAI::Internal::Type::Converter.type_info({**spec, union: type_info}), spec]
  54. in: 759 in Hash
  55. 759 [OpenAI::Internal::Type::Converter.type_info(type_info), type_info]
  56. end
  57. 2923 setter = :"#{name_sym}="
  58. 2923 api_name = info.fetch(:api_name, name_sym)
  59. 2923 nilable = info.fetch(:nil?, false)
  60. 2923 then: 1785 else: 1138 const = required && !nilable ? info.fetch(:const, OpenAI::Internal::OMIT) : OpenAI::Internal::OMIT
  61. 2927 then: 2 else: 2921 [name_sym, setter].each { undef_method(_1) } if known_fields.key?(name_sym)
  62. 2923 known_fields[name_sym] =
  63. {
  64. mode: @mode,
  65. api_name: api_name,
  66. required: required,
  67. nilable: nilable,
  68. const: const,
  69. type_fn: type_fn
  70. }
  71. 2923 define_method(setter) do |value|
  72. target = type_fn.call
  73. state = OpenAI::Internal::Type::Converter.new_coerce_state(translate_names: false)
  74. coerced = OpenAI::Internal::Type::Converter.coerce(target, value, state: state)
  75. error = @coerced.store(name_sym, state.fetch(:error) || true)
  76. stored =
  77. case [target, error]
  78. in: 0 in [OpenAI::Internal::Type::Converter | Symbol, nil]
  79. coerced
  80. else: 0 else
  81. value
  82. end
  83. @data.store(name_sym, stored)
  84. end
  85. # rubocop:disable Style/CaseEquality
  86. # rubocop:disable Metrics/BlockLength
  87. 2923 define_method(name_sym) do
  88. target = type_fn.call
  89. case @coerced[name_sym]
  90. in: 0 in true | false if OpenAI::Internal::Type::Converter === target
  91. @data.fetch(name_sym)
  92. in: 0 in ::StandardError => e
  93. raise OpenAI::Errors::ConversionError.new(
  94. on: self.class,
  95. method: __method__,
  96. target: target,
  97. value: @data.fetch(name_sym),
  98. cause: e
  99. )
  100. else: 0 else
  101. Kernel.then do
  102. then: 0 else: 0 value = @data.fetch(name_sym) { const == OpenAI::Internal::OMIT ? nil : const }
  103. state = OpenAI::Internal::Type::Converter.new_coerce_state(translate_names: false)
  104. then: 0 if (nilable || !required) && value.nil?
  105. nil
  106. else: 0 else
  107. OpenAI::Internal::Type::Converter.coerce(
  108. target, value, state: state
  109. )
  110. end
  111. rescue StandardError => e
  112. raise OpenAI::Errors::ConversionError.new(
  113. on: self.class,
  114. method: __method__,
  115. target: target,
  116. value: value,
  117. cause: e
  118. )
  119. end
  120. end
  121. end
  122. # rubocop:enable Metrics/BlockLength
  123. # rubocop:enable Style/CaseEquality
  124. end
  125. # @api private
  126. #
  127. # @param name_sym [Symbol]
  128. #
  129. # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class]
  130. #
  131. # @param spec [Hash{Symbol=>Object}] .
  132. #
  133. # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
  134. #
  135. # @option spec [Proc] :enum
  136. #
  137. # @option spec [Proc] :union
  138. #
  139. # @option spec [Boolean] :"nil?"
  140. 1 def required(name_sym, type_info, spec = {})
  141. 1878 add_field(name_sym, required: true, type_info: type_info, spec: spec)
  142. end
  143. # @api private
  144. #
  145. # @param name_sym [Symbol]
  146. #
  147. # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class]
  148. #
  149. # @param spec [Hash{Symbol=>Object}] .
  150. #
  151. # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
  152. #
  153. # @option spec [Proc] :enum
  154. #
  155. # @option spec [Proc] :union
  156. #
  157. # @option spec [Boolean] :"nil?"
  158. 1 def optional(name_sym, type_info, spec = {})
  159. 1045 add_field(name_sym, required: false, type_info: type_info, spec: spec)
  160. end
  161. # @api private
  162. #
  163. # `request_only` attributes not excluded from `.#coerce` when receiving responses
  164. # even if well behaved servers should not send them
  165. #
  166. # @param blk [Proc]
  167. 1 private def request_only(&blk)
  168. @mode = :dump
  169. blk.call
  170. ensure
  171. @mode = nil
  172. end
  173. # @api private
  174. #
  175. # `response_only` attributes are omitted from `.#dump` when making requests
  176. #
  177. # @param blk [Proc]
  178. 1 private def response_only(&blk)
  179. @mode = :coerce
  180. blk.call
  181. ensure
  182. @mode = nil
  183. end
  184. # @api public
  185. #
  186. # @param other [Object]
  187. #
  188. # @return [Boolean]
  189. 1 def ==(other)
  190. other.is_a?(Class) && other <= OpenAI::Internal::Type::BaseModel && other.fields == fields
  191. end
  192. # @api public
  193. #
  194. # @return [Integer]
  195. 1 def hash = fields.hash
  196. end
  197. # @api public
  198. #
  199. # @param other [Object]
  200. #
  201. # @return [Boolean]
  202. 1 def ==(other) = self.class == other.class && @data == other.to_h
  203. # @api public
  204. #
  205. # @return [Integer]
  206. 1 def hash = [self.class, @data].hash
  207. 1 class << self
  208. # @api private
  209. #
  210. # @param value [OpenAI::Internal::Type::BaseModel, Hash{Object=>Object}, Object]
  211. #
  212. # @param state [Hash{Symbol=>Object}] .
  213. #
  214. # @option state [Boolean] :translate_names
  215. #
  216. # @option state [Boolean] :strictness
  217. #
  218. # @option state [Hash{Symbol=>Object}] :exactness
  219. #
  220. # @option state [Class<StandardError>] :error
  221. #
  222. # @option state [Integer] :branched
  223. #
  224. # @return [self, Object]
  225. 1 def coerce(value, state:)
  226. exactness = state.fetch(:exactness)
  227. then: 0 else: 0 if value.is_a?(self.class)
  228. exactness[:yes] += 1
  229. return value
  230. end
  231. else: 0 then: 0 unless (val = OpenAI::Internal::Util.coerce_hash(value)).is_a?(Hash)
  232. exactness[:no] += 1
  233. state[:error] = TypeError.new("#{value.class} can't be coerced into #{Hash}")
  234. return value
  235. end
  236. exactness[:yes] += 1
  237. keys = val.keys.to_set
  238. instance = new
  239. data = instance.to_h
  240. viability = instance.instance_variable_get(:@coerced)
  241. # rubocop:disable Metrics/BlockLength
  242. fields.each do |name, field|
  243. mode, required, target = field.fetch_values(:mode, :required, :type)
  244. api_name, nilable, const = field.fetch_values(:api_name, :nilable, :const)
  245. then: 0 else: 0 src_name = state.fetch(:translate_names) ? api_name : name
  246. else: 0 then: 0 unless val.key?(src_name)
  247. then: 0 if required && mode != :dump && const == OpenAI::Internal::OMIT
  248. then: 0 else: 0 exactness[nilable ? :maybe : :no] += 1
  249. else: 0 else
  250. exactness[:yes] += 1
  251. end
  252. next
  253. end
  254. item = val.fetch(src_name)
  255. keys.delete(src_name)
  256. state[:error] = nil
  257. converted =
  258. then: 0 if item.nil? && (nilable || !required)
  259. then: 0 else: 0 exactness[nilable ? :yes : :maybe] += 1
  260. nil
  261. else: 0 else
  262. coerced = OpenAI::Internal::Type::Converter.coerce(target, item, state: state)
  263. case target
  264. in: 0 in OpenAI::Internal::Type::Converter | Symbol
  265. coerced
  266. else: 0 else
  267. item
  268. end
  269. end
  270. viability.store(name, state.fetch(:error) || true)
  271. data.store(name, converted)
  272. end
  273. # rubocop:enable Metrics/BlockLength
  274. keys.each { data.store(_1, val.fetch(_1)) }
  275. instance
  276. end
  277. # @api private
  278. #
  279. # @param value [self, Object]
  280. #
  281. # @param state [Hash{Symbol=>Object}] .
  282. #
  283. # @option state [Boolean] :can_retry
  284. #
  285. # @return [Hash{Object=>Object}, Object]
  286. 1 def dump(value, state:)
  287. 2 else: 2 then: 0 unless (coerced = OpenAI::Internal::Util.coerce_hash(value)).is_a?(Hash)
  288. return super
  289. end
  290. 2 acc = {}
  291. 2 coerced.each do |key, val|
  292. 6 then: 0 else: 6 name = key.is_a?(String) ? key.to_sym : key
  293. case (field = known_fields[name])
  294. 6 in: 0 in nil
  295. acc.store(name, super(val, state: state))
  296. else: 6 else
  297. 6 api_name, mode, type_fn = field.fetch_values(:api_name, :mode, :type_fn)
  298. case mode
  299. 6 in: 0 in :coerce
  300. next
  301. else: 6 else
  302. 6 target = type_fn.call
  303. 6 acc.store(api_name, OpenAI::Internal::Type::Converter.dump(target, val, state: state))
  304. end
  305. end
  306. end
  307. 2 known_fields.each_value do |field|
  308. 50 api_name, mode, const = field.fetch_values(:api_name, :mode, :const)
  309. 50 then: 50 else: 0 next if mode == :coerce || acc.key?(api_name) || const == OpenAI::Internal::OMIT
  310. acc.store(api_name, const)
  311. end
  312. 2 acc
  313. end
  314. # @api private
  315. #
  316. # @return [Object]
  317. 1 def to_sorbet_type
  318. self
  319. end
  320. end
  321. 1 class << self
  322. # @api private
  323. #
  324. # @param model [OpenAI::Internal::Type::BaseModel]
  325. # @param convert [Boolean]
  326. #
  327. # @return [Hash{Symbol=>Object}]
  328. 1 def recursively_to_h(model, convert:)
  329. rec = ->(x) do
  330. case x
  331. in: 0 in OpenAI::Internal::Type::BaseModel
  332. then: 0 if convert
  333. fields = x.class.known_fields
  334. x.to_h.to_h do |key, val|
  335. then: 0 else: 0 [key, rec.call(fields.key?(key) ? x.public_send(key) : val)]
  336. rescue OpenAI::Errors::ConversionError
  337. [key, rec.call(val)]
  338. end
  339. else: 0 else
  340. rec.call(x.to_h)
  341. end
  342. in: 0 in Hash
  343. x.transform_values(&rec)
  344. in: 0 in Array
  345. x.map(&rec)
  346. else: 0 else
  347. x
  348. end
  349. end
  350. rec.call(model)
  351. end
  352. end
  353. # @api public
  354. #
  355. # Returns the raw value associated with the given key, if found. Otherwise, nil is
  356. # returned.
  357. #
  358. # It is valid to lookup keys that are not in the API spec, for example to access
  359. # undocumented features. This method does not parse response data into
  360. # higher-level types. Lookup by anything other than a Symbol is an ArgumentError.
  361. #
  362. # @param key [Symbol]
  363. #
  364. # @return [Object, nil]
  365. 1 def [](key)
  366. else: 0 then: 0 unless key.instance_of?(Symbol)
  367. raise ArgumentError.new("Expected symbol key for lookup, got #{key.inspect}")
  368. end
  369. @data[key]
  370. end
  371. # @api public
  372. #
  373. # Returns a Hash of the data underlying this object. O(1)
  374. #
  375. # Keys are Symbols and values are the raw values from the response. The return
  376. # value indicates which values were ever set on the object. i.e. there will be a
  377. # key in this hash if they ever were, even if the set value was nil.
  378. #
  379. # This method is not recursive. The returned value is shared by the object, so it
  380. # should not be mutated.
  381. #
  382. # @return [Hash{Symbol=>Object}]
  383. 1 def to_h = @data
  384. 1 alias_method :to_hash, :to_h
  385. # @api public
  386. #
  387. # In addition to the behaviour of `#to_h`, this method will recursively call
  388. # `#to_h` on nested models.
  389. #
  390. # @return [Hash{Symbol=>Object}]
  391. 1 def deep_to_h = self.class.recursively_to_h(@data, convert: false)
  392. # @param keys [Array<Symbol>, nil]
  393. #
  394. # @return [Hash{Symbol=>Object}]
  395. #
  396. # @example
  397. # # `comparison_filter` is a `OpenAI::ComparisonFilter`
  398. # comparison_filter => {
  399. # key: key,
  400. # type: type,
  401. # value: value
  402. # }
  403. 1 def deconstruct_keys(keys)
  404. (keys || self.class.known_fields.keys)
  405. .filter_map do |k|
  406. else: 0 then: 0 unless self.class.known_fields.key?(k)
  407. next
  408. end
  409. [k, public_send(k)]
  410. end
  411. .to_h
  412. end
  413. # @api public
  414. #
  415. # @param a [Object]
  416. #
  417. # @return [String]
  418. 1 def to_json(*a) = OpenAI::Internal::Type::Converter.dump(self.class, self).to_json(*a)
  419. # @api public
  420. #
  421. # @param a [Object]
  422. #
  423. # @return [String]
  424. 1 def to_yaml(*a) = OpenAI::Internal::Type::Converter.dump(self.class, self).to_yaml(*a)
  425. # Create a new instance of a model.
  426. #
  427. # @param data [Hash{Symbol=>Object}, self]
  428. 1 def initialize(data = {})
  429. @data = {}
  430. @coerced = {}
  431. OpenAI::Internal::Util.coerce_hash!(data).each do
  432. then: 0 if self.class.known_fields.key?(_1)
  433. public_send(:"#{_1}=", _2)
  434. else: 0 else
  435. @data.store(_1, _2)
  436. @coerced.store(_1, false)
  437. end
  438. end
  439. end
  440. 1 class << self
  441. # @api private
  442. #
  443. # @param depth [Integer]
  444. #
  445. # @return [String]
  446. 1 def inspect(depth: 0)
  447. then: 0 else: 0 return super() if depth.positive?
  448. depth = depth.succ
  449. deferred = fields.transform_values do |field|
  450. type, required, nilable = field.fetch_values(:type, :required, :nilable)
  451. inspected = [
  452. OpenAI::Internal::Type::Converter.inspect(type, depth: depth),
  453. then: 0 else: 0 !required || nilable ? "nil" : nil
  454. ].compact.join(" | ")
  455. -> { inspected }.tap { _1.define_singleton_method(:inspect) { call } }
  456. end
  457. "#{name}[#{deferred.inspect}]"
  458. end
  459. end
  460. # @api public
  461. #
  462. # @return [String]
  463. 1 def to_s = deep_to_h.to_s
  464. # @api private
  465. #
  466. # @return [String]
  467. 1 def inspect
  468. converted = self.class.recursively_to_h(self, convert: true)
  469. "#<#{self.class}:0x#{object_id.to_s(16)} #{converted}>"
  470. end
  471. 1 define_sorbet_constant!(:KnownField) do
  472. T.type_alias { {mode: T.nilable(Symbol), required: T::Boolean, nilable: T::Boolean} }
  473. end
  474. end
  475. end
  476. end
  477. end

openai-ruby/lib/openai/internal/type/base_page.rb

71.43% lines covered

100.0% branches covered

14 relevant lines. 10 lines covered and 4 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. #
  7. # @generic Elem
  8. #
  9. # This module provides a base implementation for paginated responses in the SDK.
  10. 1 module BasePage
  11. # rubocop:disable Lint/UnusedMethodArgument
  12. # @api public
  13. #
  14. # @return [Boolean]
  15. 1 def next_page? = (raise NotImplementedError)
  16. # @api public
  17. #
  18. # @raise [OpenAI::Errors::APIError]
  19. # @return [self]
  20. 1 def next_page = (raise NotImplementedError)
  21. # @api public
  22. #
  23. # @param blk [Proc]
  24. #
  25. # @yieldparam [generic<Elem>]
  26. # @return [void]
  27. 1 def auto_paging_each(&blk) = (raise NotImplementedError)
  28. # @return [Enumerable<generic<Elem>>]
  29. 1 def to_enum = super(:auto_paging_each)
  30. 1 alias_method :enum_for, :to_enum
  31. # @api private
  32. #
  33. # @param client [OpenAI::Internal::Transport::BaseClient]
  34. # @param req [Hash{Symbol=>Object}]
  35. # @param headers [Hash{String=>String}, Net::HTTPHeader]
  36. # @param page_data [Object]
  37. 1 def initialize(client:, req:, headers:, page_data:)
  38. @client = client
  39. @req = req
  40. @model = req.fetch(:model)
  41. super()
  42. end
  43. # rubocop:enable Lint/UnusedMethodArgument
  44. end
  45. end
  46. end
  47. end

openai-ruby/lib/openai/internal/type/base_stream.rb

51.85% lines covered

0.0% branches covered

27 relevant lines. 14 lines covered and 13 lines missed.
2 total branches, 0 branches covered and 2 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. #
  7. # @generic Elem
  8. #
  9. # This module provides a base implementation for streaming responses in the SDK.
  10. #
  11. # @see https://rubyapi.org/3.2/o/enumerable
  12. 1 module BaseStream
  13. 1 include Enumerable
  14. 1 class << self
  15. # Attempt to close the underlying transport when the stream itself is garbage
  16. # collected.
  17. #
  18. # This should not be relied upon for resource clean up, as the garbage collector
  19. # is not guaranteed to run.
  20. #
  21. # @param stream [Enumerable<Object>]
  22. #
  23. # @return [Proc]
  24. #
  25. # @see https://rubyapi.org/3.2/o/objectspace#method-c-define_finalizer
  26. 1 def defer_closing(stream) = ->(_id) { OpenAI::Internal::Util.close_fused!(stream) }
  27. end
  28. # @api public
  29. #
  30. # @return [void]
  31. 1 def close = OpenAI::Internal::Util.close_fused!(@iterator)
  32. # @api private
  33. #
  34. # @return [Enumerable<generic<Elem>>]
  35. 1 private def iterator = (raise NotImplementedError)
  36. # @api public
  37. #
  38. # @param blk [Proc]
  39. #
  40. # @yieldparam [generic<Elem>]
  41. # @return [void]
  42. 1 def each(&blk)
  43. else: 0 then: 0 unless block_given?
  44. raise ArgumentError.new("A block must be given to ##{__method__}")
  45. end
  46. @iterator.each(&blk)
  47. end
  48. # @api public
  49. #
  50. # @return [Enumerator<generic<Elem>>]
  51. 1 def to_enum = @iterator
  52. 1 alias_method :enum_for, :to_enum
  53. # @api private
  54. #
  55. # @param model [Class, OpenAI::Internal::Type::Converter]
  56. # @param url [URI::Generic]
  57. # @param status [Integer]
  58. # @param response [Net::HTTPResponse]
  59. # @param unwrap [Symbol, Integer, Array<Symbol, Integer>, Proc]
  60. # @param stream [Enumerable<Object>]
  61. 1 def initialize(model:, url:, status:, response:, unwrap:, stream:)
  62. @model = model
  63. @url = url
  64. @status = status
  65. @response = response
  66. @unwrap = unwrap
  67. @stream = stream
  68. @iterator = iterator
  69. ObjectSpace.define_finalizer(self, OpenAI::Internal::Type::BaseStream.defer_closing(@stream))
  70. end
  71. # @api private
  72. #
  73. # @return [String]
  74. 1 def inspect
  75. model = OpenAI::Internal::Type::Converter.inspect(@model, depth: 1)
  76. "#<#{self.class}[#{model}]:0x#{object_id.to_s(16)}>"
  77. end
  78. end
  79. end
  80. end
  81. end

openai-ruby/lib/openai/internal/type/boolean.rb

80.0% lines covered

0.0% branches covered

15 relevant lines. 12 lines covered and 3 lines missed.
2 total branches, 0 branches covered and 2 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. #
  7. # @abstract
  8. #
  9. # Ruby has no Boolean class; this is something for models to refer to.
  10. 1 class Boolean
  11. 1 extend OpenAI::Internal::Type::Converter
  12. 1 extend OpenAI::Internal::Util::SorbetRuntimeSupport
  13. 1 private_class_method :new
  14. # @api public
  15. #
  16. # @param other [Object]
  17. #
  18. # @return [Boolean]
  19. 1 def self.===(other) = other == true || other == false
  20. # @api public
  21. #
  22. # @param other [Object]
  23. #
  24. # @return [Boolean]
  25. 1 def self.==(other) = other.is_a?(Class) && other <= OpenAI::Internal::Type::Boolean
  26. 1 class << self
  27. # @api private
  28. #
  29. # Coerce value to Boolean if possible, otherwise return the original value.
  30. #
  31. # @param value [Boolean, Object]
  32. #
  33. # @param state [Hash{Symbol=>Object}] .
  34. #
  35. # @option state [Boolean] :translate_names
  36. #
  37. # @option state [Boolean] :strictness
  38. #
  39. # @option state [Hash{Symbol=>Object}] :exactness
  40. #
  41. # @option state [Class<StandardError>] :error
  42. #
  43. # @option state [Integer] :branched
  44. #
  45. # @return [Boolean, Object]
  46. 1 def coerce(value, state:)
  47. then: 0 else: 0 state.fetch(:exactness)[value == true || value == false ? :yes : :no] += 1
  48. value
  49. end
  50. # @!method dump(value, state:)
  51. # @api private
  52. #
  53. # @param value [Boolean, Object]
  54. #
  55. # @param state [Hash{Symbol=>Object}] .
  56. #
  57. # @option state [Boolean] :can_retry
  58. #
  59. # @return [Boolean, Object]
  60. # @api private
  61. #
  62. # @return [Object]
  63. 1 def to_sorbet_type
  64. T::Boolean
  65. end
  66. end
  67. end
  68. end
  69. end
  70. end

openai-ruby/lib/openai/internal/type/converter.rb

43.48% lines covered

25.49% branches covered

92 relevant lines. 40 lines covered and 52 lines missed.
51 total branches, 13 branches covered and 38 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. 1 module Converter
  7. 1 extend OpenAI::Internal::Util::SorbetRuntimeSupport
  8. # rubocop:disable Lint/UnusedMethodArgument
  9. # @api private
  10. #
  11. # @param value [Object]
  12. #
  13. # @param state [Hash{Symbol=>Object}] .
  14. #
  15. # @option state [Boolean] :translate_names
  16. #
  17. # @option state [Boolean] :strictness
  18. #
  19. # @option state [Hash{Symbol=>Object}] :exactness
  20. #
  21. # @option state [Class<StandardError>] :error
  22. #
  23. # @option state [Integer] :branched
  24. #
  25. # @return [Object]
  26. 1 def coerce(value, state:) = (raise NotImplementedError)
  27. # @api private
  28. #
  29. # @param value [Object]
  30. #
  31. # @param state [Hash{Symbol=>Object}] .
  32. #
  33. # @option state [Boolean] :can_retry
  34. #
  35. # @return [Object]
  36. 1 def dump(value, state:)
  37. case value
  38. 49 in: 4 in Array
  39. 11 value.map { OpenAI::Internal::Type::Unknown.dump(_1, state: state) }
  40. in: 17 in Hash
  41. 53 value.transform_values { OpenAI::Internal::Type::Unknown.dump(_1, state: state) }
  42. in: 0 in OpenAI::Internal::Type::BaseModel
  43. value.class.dump(value, state: state)
  44. in: 0 in StringIO
  45. value.string
  46. in: 0 in Pathname | IO
  47. then: 0 else: 0 state[:can_retry] = false if value.is_a?(IO)
  48. OpenAI::FilePart.new(value)
  49. in: 0 in OpenAI::FilePart
  50. then: 0 else: 0 state[:can_retry] = false if value.content.is_a?(IO)
  51. value
  52. else: 28 else
  53. 28 value
  54. end
  55. end
  56. # @api private
  57. #
  58. # @param depth [Integer]
  59. #
  60. # @return [String]
  61. 1 def inspect(depth: 0)
  62. super()
  63. end
  64. # rubocop:enable Lint/UnusedMethodArgument
  65. 1 class << self
  66. # @api private
  67. #
  68. # @param spec [Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class] .
  69. #
  70. # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
  71. #
  72. # @option spec [Proc] :enum
  73. #
  74. # @option spec [Proc] :union
  75. #
  76. # @option spec [Boolean] :"nil?"
  77. #
  78. # @return [Proc]
  79. 1 def type_info(spec)
  80. else: 0 case spec
  81. 6860 in: 1388 in Proc
  82. 1388 spec
  83. in: 3035 in Hash
  84. 3035 then: 3035 else: 0 type_info(spec.slice(:const, :enum, :union).first&.last)
  85. in: 0 in true | false
  86. -> { OpenAI::Internal::Type::Boolean }
  87. in: 2437 in OpenAI::Internal::Type::Converter | Class | Symbol
  88. 2441 -> { spec }
  89. in: 0 in NilClass | Integer | Float
  90. -> { spec.class }
  91. end
  92. end
  93. # @api private
  94. #
  95. # @param translate_names [Boolean]
  96. #
  97. # @return [Hash{Symbol=>Object}]
  98. 1 def new_coerce_state(translate_names: true)
  99. {
  100. 6 translate_names: translate_names,
  101. strictness: true,
  102. exactness: {yes: 0, no: 0, maybe: 0},
  103. error: nil,
  104. branched: 0
  105. }
  106. end
  107. # @api private
  108. #
  109. # Based on `target`, transform `value` into `target`, to the extent possible:
  110. #
  111. # 1. if the given `value` conforms to `target` already, return the given `value`
  112. # 2. if it's possible and safe to convert the given `value` to `target`, then the
  113. # converted value
  114. # 3. otherwise, the given `value` unaltered
  115. #
  116. # The coercion process is subject to improvement between minor release versions.
  117. # See https://docs.pydantic.dev/latest/concepts/unions/#smart-mode
  118. #
  119. # @param target [OpenAI::Internal::Type::Converter, Class]
  120. #
  121. # @param value [Object]
  122. #
  123. # @param state [Hash{Symbol=>Object}] The `strictness` is one of `true`, `false`. This informs the coercion strategy
  124. # when we have to decide between multiple possible conversion targets:
  125. #
  126. # - `true`: the conversion must be exact, with minimum coercion.
  127. # - `false`: the conversion can be approximate, with some coercion.
  128. #
  129. # The `exactness` is `Hash` with keys being one of `yes`, `no`, or `maybe`. For
  130. # any given conversion attempt, the exactness will be updated based on how closely
  131. # the value recursively matches the target type:
  132. #
  133. # - `yes`: the value can be converted to the target type with minimum coercion.
  134. # - `maybe`: the value can be converted to the target type with some reasonable
  135. # coercion.
  136. # - `no`: the value cannot be converted to the target type.
  137. #
  138. # See implementation below for more details.
  139. #
  140. # @option state [Boolean] :translate_names
  141. #
  142. # @option state [Boolean] :strictness
  143. #
  144. # @option state [Hash{Symbol=>Object}] :exactness
  145. #
  146. # @option state [Class<StandardError>] :error
  147. #
  148. # @option state [Integer] :branched
  149. #
  150. # @return [Object]
  151. 1 def coerce(target, value, state: OpenAI::Internal::Type::Converter.new_coerce_state)
  152. # rubocop:disable Metrics/BlockNesting
  153. 6 exactness = state.fetch(:exactness)
  154. case target
  155. 6 in: 0 in OpenAI::Internal::Type::Converter
  156. return target.coerce(value, state: state)
  157. in: 6 in Class
  158. 6 then: 0 else: 6 if value.is_a?(target)
  159. exactness[:yes] += 1
  160. return value
  161. end
  162. case target
  163. 12 in: 0 in -> { _1 <= NilClass }
  164. then: 0 else: 0 exactness[value.nil? ? :yes : :maybe] += 1
  165. return nil
  166. 6 in: 0 in -> { _1 <= Integer }
  167. case value
  168. in: 0 in Integer
  169. exactness[:yes] += 1
  170. return value
  171. else: 0 else
  172. Kernel.then do
  173. return Integer(value).tap { exactness[:maybe] += 1 }
  174. rescue ArgumentError, TypeError => e
  175. state[:error] = e
  176. end
  177. end
  178. 6 in: 0 in -> { _1 <= Float }
  179. then: 0 if value.is_a?(Numeric)
  180. exactness[:yes] += 1
  181. return Float(value)
  182. else: 0 else
  183. Kernel.then do
  184. return Float(value).tap { exactness[:maybe] += 1 }
  185. rescue ArgumentError, TypeError => e
  186. state[:error] = e
  187. end
  188. end
  189. 6 in: 6 in -> { _1 <= String }
  190. case value
  191. 6 in: 0 in String | Symbol | Numeric
  192. then: 0 else: 0 exactness[value.is_a?(Numeric) ? :maybe : :yes] += 1
  193. return value.to_s
  194. in: 0 in StringIO
  195. exactness[:yes] += 1
  196. return value.string
  197. else: 6 else
  198. 6 state[:error] = TypeError.new("#{value.class} can't be coerced into #{String}")
  199. end
  200. in: 0 in -> { _1 <= Date || _1 <= Time }
  201. Kernel.then do
  202. return target.parse(value).tap { exactness[:yes] += 1 }
  203. rescue ArgumentError, TypeError => e
  204. state[:error] = e
  205. end
  206. in: 0 in -> { _1 <= StringIO } if value.is_a?(String)
  207. exactness[:yes] += 1
  208. else: 0 return StringIO.new(value.b)
  209. else
  210. end
  211. in: 0 in Symbol
  212. case value
  213. in: 0 in Symbol | String
  214. then: 0 if value.to_sym == target
  215. exactness[:yes] += 1
  216. return target
  217. else: 0 else
  218. exactness[:maybe] += 1
  219. return value
  220. end
  221. else: 0 else
  222. message = "cannot convert non-matching #{value.class} into #{target.inspect}"
  223. state[:error] = ArgumentError.new(message)
  224. else: 0 end
  225. else
  226. end
  227. 6 exactness[:no] += 1
  228. 6 value
  229. # rubocop:enable Metrics/BlockNesting
  230. end
  231. # @api private
  232. #
  233. # @param target [OpenAI::Internal::Type::Converter, Class]
  234. #
  235. # @param value [Object]
  236. #
  237. # @param state [Hash{Symbol=>Object}] .
  238. #
  239. # @option state [Boolean] :can_retry
  240. #
  241. # @return [Object]
  242. 1 def dump(target, value, state: {can_retry: true})
  243. case target
  244. 8 in: 6 in OpenAI::Internal::Type::Converter
  245. 6 target.dump(value, state: state)
  246. else: 2 else
  247. 2 OpenAI::Internal::Type::Unknown.dump(value, state: state)
  248. end
  249. end
  250. # @api private
  251. #
  252. # @param target [Object]
  253. # @param depth [Integer]
  254. #
  255. # @return [String]
  256. 1 def inspect(target, depth:)
  257. case target
  258. in: 0 in OpenAI::Internal::Type::Converter
  259. target.inspect(depth: depth.succ)
  260. else: 0 else
  261. target.inspect
  262. end
  263. end
  264. end
  265. 1 define_sorbet_constant!(:Input) do
  266. T.type_alias { T.any(OpenAI::Internal::Type::Converter, T::Class[T.anything]) }
  267. end
  268. 1 define_sorbet_constant!(:CoerceState) do
  269. T.type_alias do
  270. {
  271. translate_names: T::Boolean,
  272. strictness: T::Boolean,
  273. exactness: {yes: Integer, no: Integer, maybe: Integer},
  274. error: T::Class[StandardError],
  275. branched: Integer
  276. }
  277. end
  278. end
  279. 1 define_sorbet_constant!(:DumpState) do
  280. T.type_alias { {can_retry: T::Boolean} }
  281. end
  282. end
  283. end
  284. end
  285. end

openai-ruby/lib/openai/internal/type/enum.rb

37.14% lines covered

0.0% branches covered

35 relevant lines. 13 lines covered and 22 lines missed.
17 total branches, 0 branches covered and 17 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. #
  7. # A value from among a specified list of options. OpenAPI enum values map to Ruby
  8. # values in the SDK as follows:
  9. #
  10. # 1. boolean => true | false
  11. # 2. integer => Integer
  12. # 3. float => Float
  13. # 4. string => Symbol
  14. #
  15. # We can therefore convert string values to Symbols, but can't convert other
  16. # values safely.
  17. #
  18. # @example
  19. # # `chat_model` is a `OpenAI::ChatModel`
  20. # case chat_model
  21. # when OpenAI::ChatModel::GPT_4_1
  22. # # ...
  23. # when OpenAI::ChatModel::GPT_4_1_MINI
  24. # # ...
  25. # when OpenAI::ChatModel::GPT_4_1_NANO
  26. # # ...
  27. # else
  28. # puts(chat_model)
  29. # end
  30. #
  31. # @example
  32. # case chat_model
  33. # in :"gpt-4.1"
  34. # # ...
  35. # in :"gpt-4.1-mini"
  36. # # ...
  37. # in :"gpt-4.1-nano"
  38. # # ...
  39. # else
  40. # puts(chat_model)
  41. # end
  42. 1 module Enum
  43. 1 include OpenAI::Internal::Type::Converter
  44. 1 include OpenAI::Internal::Util::SorbetRuntimeSupport
  45. # All of the valid Symbol values for this enum.
  46. #
  47. # @return [Array<NilClass, Boolean, Integer, Float, Symbol>]
  48. 1 def values = constants.map { const_get(_1) }
  49. # @api public
  50. #
  51. # @param other [Object]
  52. #
  53. # @return [Boolean]
  54. 1 def ===(other) = values.include?(other)
  55. # @api public
  56. #
  57. # @param other [Object]
  58. #
  59. # @return [Boolean]
  60. 1 def ==(other)
  61. # rubocop:disable Style/CaseEquality
  62. OpenAI::Internal::Type::Enum === other && other.values.to_set == values.to_set
  63. # rubocop:enable Style/CaseEquality
  64. end
  65. # @api public
  66. #
  67. # @return [Integer]
  68. 1 def hash = values.to_set.hash
  69. # @api private
  70. #
  71. # Unlike with primitives, `Enum` additionally validates that the value is a member
  72. # of the enum.
  73. #
  74. # @param value [String, Symbol, Object]
  75. #
  76. # @param state [Hash{Symbol=>Object}] .
  77. #
  78. # @option state [Boolean] :translate_names
  79. #
  80. # @option state [Boolean] :strictness
  81. #
  82. # @option state [Hash{Symbol=>Object}] :exactness
  83. #
  84. # @option state [Class<StandardError>] :error
  85. #
  86. # @option state [Integer] :branched
  87. #
  88. # @return [Symbol, Object]
  89. 1 def coerce(value, state:)
  90. exactness = state.fetch(:exactness)
  91. then: 0 else: 0 val = value.is_a?(String) ? value.to_sym : value
  92. then: 0 if values.include?(val)
  93. exactness[:yes] += 1
  94. else: 0 val
  95. then: 0 else: 0 then: 0 elsif values.first&.class == val.class
  96. exactness[:maybe] += 1
  97. value
  98. else: 0 else
  99. exactness[:no] += 1
  100. state[:error] = TypeError.new("#{value.class} can't be coerced into #{self}")
  101. value
  102. end
  103. end
  104. # @!method dump(value, state:)
  105. # @api private
  106. #
  107. # @param value [Symbol, Object]
  108. #
  109. # @param state [Hash{Symbol=>Object}] .
  110. #
  111. # @option state [Boolean] :can_retry
  112. #
  113. # @return [Symbol, Object]
  114. # @api private
  115. #
  116. # @return [Object]
  117. 1 def to_sorbet_type
  118. types = values.map { OpenAI::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
  119. case types
  120. in: 0 in []
  121. T.noreturn
  122. in: 0 in [type]
  123. type
  124. else: 0 else
  125. T.any(*types)
  126. end
  127. end
  128. # @api private
  129. #
  130. # @param depth [Integer]
  131. #
  132. # @return [String]
  133. 1 def inspect(depth: 0)
  134. then: 0 else: 0 if depth.positive?
  135. then: 0 else: 0 return is_a?(Module) ? super() : self.class.name
  136. end
  137. members = values.map { OpenAI::Internal::Type::Converter.inspect(_1, depth: depth.succ) }
  138. then: 0 else: 0 prefix = is_a?(Module) ? name : self.class.name
  139. "#{prefix}[#{members.join(' | ')}]"
  140. end
  141. end
  142. end
  143. end
  144. end

openai-ruby/lib/openai/internal/type/file_input.rb

41.38% lines covered

0.0% branches covered

29 relevant lines. 12 lines covered and 17 lines missed.
8 total branches, 0 branches covered and 8 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. #
  7. # @abstract
  8. #
  9. # Either `Pathname` or `StringIO`, or `IO`, or
  10. # `OpenAI::Internal::Type::FileInput`.
  11. #
  12. # Note: when `IO` is used, all retries are disabled, since many IO` streams are
  13. # not rewindable.
  14. 1 class FileInput
  15. 1 extend OpenAI::Internal::Type::Converter
  16. 1 private_class_method :new
  17. # @api public
  18. #
  19. # @param other [Object]
  20. #
  21. # @return [Boolean]
  22. 1 def self.===(other)
  23. case other
  24. in: 0 in Pathname | StringIO | IO | String | OpenAI::FilePart
  25. true
  26. else: 0 else
  27. false
  28. end
  29. end
  30. # @api public
  31. #
  32. # @param other [Object]
  33. #
  34. # @return [Boolean]
  35. 1 def self.==(other) = other.is_a?(Class) && other <= OpenAI::Internal::Type::FileInput
  36. 1 class << self
  37. # @api private
  38. #
  39. # @param value [StringIO, String, Object]
  40. #
  41. # @param state [Hash{Symbol=>Object}] .
  42. #
  43. # @option state [Boolean] :translate_names
  44. #
  45. # @option state [Boolean] :strictness
  46. #
  47. # @option state [Hash{Symbol=>Object}] :exactness
  48. #
  49. # @option state [Class<StandardError>] :error
  50. #
  51. # @option state [Integer] :branched
  52. #
  53. # @return [StringIO, Object]
  54. 1 def coerce(value, state:)
  55. exactness = state.fetch(:exactness)
  56. case value
  57. in: 0 in String
  58. exactness[:yes] += 1
  59. StringIO.new(value)
  60. in: 0 in StringIO
  61. exactness[:yes] += 1
  62. value
  63. else: 0 else
  64. state[:error] = TypeError.new("#{value.class} can't be coerced into #{StringIO}")
  65. exactness[:no] += 1
  66. value
  67. end
  68. end
  69. # @api private
  70. #
  71. # @param value [Pathname, StringIO, IO, String, Object]
  72. #
  73. # @param state [Hash{Symbol=>Object}] .
  74. #
  75. # @option state [Boolean] :can_retry
  76. #
  77. # @return [Pathname, StringIO, IO, String, Object]
  78. 1 def dump(value, state:)
  79. # rubocop:disable Lint/DuplicateBranch
  80. case value
  81. in: 0 in IO
  82. state[:can_retry] = false
  83. in: 0 in OpenAI::FilePart if value.content.is_a?(IO)
  84. else: 0 state[:can_retry] = false
  85. else
  86. end
  87. # rubocop:enable Lint/DuplicateBranch
  88. value
  89. end
  90. # @api private
  91. #
  92. # @return [Object]
  93. 1 def to_sorbet_type
  94. T.any(Pathname, StringIO, IO, String, OpenAI::FilePart)
  95. end
  96. end
  97. end
  98. end
  99. end
  100. end

openai-ruby/lib/openai/internal/type/hash_of.rb

39.22% lines covered

0.0% branches covered

51 relevant lines. 20 lines covered and 31 lines missed.
16 total branches, 0 branches covered and 16 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. #
  7. # @abstract
  8. #
  9. # @generic Elem
  10. #
  11. # Hash of items of a given type.
  12. 1 class HashOf
  13. 1 include OpenAI::Internal::Type::Converter
  14. 1 include OpenAI::Internal::Util::SorbetRuntimeSupport
  15. 1 private_class_method :new
  16. # @overload [](type_info, spec = {})
  17. #
  18. # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class]
  19. #
  20. # @param spec [Hash{Symbol=>Object}] .
  21. #
  22. # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
  23. #
  24. # @option spec [Proc] :enum
  25. #
  26. # @option spec [Proc] :union
  27. #
  28. # @option spec [Boolean] :"nil?"
  29. #
  30. # @return [self]
  31. 1 def self.[](...) = new(...)
  32. # @api public
  33. #
  34. # @param other [Object]
  35. #
  36. # @return [Boolean]
  37. 1 def ===(other)
  38. type = item_type
  39. case other
  40. in: 0 in Hash
  41. other.all? do |key, val|
  42. case [key, val]
  43. in: 0 in [Symbol | String, ^type]
  44. true
  45. else: 0 else
  46. false
  47. end
  48. end
  49. else: 0 else
  50. false
  51. end
  52. end
  53. # @api public
  54. #
  55. # @param other [Object]
  56. #
  57. # @return [Boolean]
  58. 1 def ==(other)
  59. # rubocop:disable Layout/LineLength
  60. other.is_a?(OpenAI::Internal::Type::HashOf) && other.nilable? == nilable? && other.item_type == item_type
  61. # rubocop:enable Layout/LineLength
  62. end
  63. # @api public
  64. #
  65. # @return [Integer]
  66. 1 def hash = [self.class, item_type].hash
  67. # @api private
  68. #
  69. # @param value [Hash{Object=>Object}, Object]
  70. #
  71. # @param state [Hash{Symbol=>Object}] .
  72. #
  73. # @option state [Boolean] :translate_names
  74. #
  75. # @option state [Boolean] :strictness
  76. #
  77. # @option state [Hash{Symbol=>Object}] :exactness
  78. #
  79. # @option state [Class<StandardError>] :error
  80. #
  81. # @option state [Integer] :branched
  82. #
  83. # @return [Hash{Symbol=>Object}, Object]
  84. 1 def coerce(value, state:)
  85. exactness = state.fetch(:exactness)
  86. else: 0 then: 0 unless value.is_a?(Hash)
  87. exactness[:no] += 1
  88. state[:error] = TypeError.new("#{value.class} can't be coerced into #{Hash}")
  89. return value
  90. end
  91. target = item_type
  92. exactness[:yes] += 1
  93. value
  94. .to_h do |key, val|
  95. then: 0 else: 0 k = key.is_a?(String) ? key.to_sym : key
  96. v =
  97. case [nilable?, val]
  98. in: 0 in [true, nil]
  99. exactness[:yes] += 1
  100. nil
  101. else: 0 else
  102. OpenAI::Internal::Type::Converter.coerce(target, val, state: state)
  103. end
  104. else: 0 then: 0 exactness[:no] += 1 unless k.is_a?(Symbol)
  105. [k, v]
  106. end
  107. end
  108. # @api private
  109. #
  110. # @param value [Hash{Object=>Object}, Object]
  111. #
  112. # @param state [Hash{Symbol=>Object}] .
  113. #
  114. # @option state [Boolean] :can_retry
  115. #
  116. # @return [Hash{Symbol=>Object}, Object]
  117. 1 def dump(value, state:)
  118. target = item_type
  119. then: 0 if value.is_a?(Hash)
  120. value.transform_values do
  121. OpenAI::Internal::Type::Converter.dump(target, _1, state: state)
  122. end
  123. else: 0 else
  124. super
  125. end
  126. end
  127. # @api private
  128. #
  129. # @return [Object]
  130. 1 def to_sorbet_type
  131. T::Hash[OpenAI::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(item_type)]
  132. end
  133. # @api private
  134. #
  135. # @return [generic<Elem>]
  136. 1 protected def item_type = @item_type_fn.call
  137. # @api private
  138. #
  139. # @return [Boolean]
  140. 1 protected def nilable? = @nilable
  141. # @api private
  142. #
  143. # @param type_info [Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class]
  144. #
  145. # @param spec [Hash{Symbol=>Object}] .
  146. #
  147. # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
  148. #
  149. # @option spec [Proc] :enum
  150. #
  151. # @option spec [Proc] :union
  152. #
  153. # @option spec [Boolean] :"nil?"
  154. 1 def initialize(type_info, spec = {})
  155. 96 @item_type_fn = OpenAI::Internal::Type::Converter.type_info(type_info || spec)
  156. 96 @nilable = spec.fetch(:nil?, false)
  157. end
  158. # @api private
  159. #
  160. # @param depth [Integer]
  161. #
  162. # @return [String]
  163. 1 def inspect(depth: 0)
  164. items = OpenAI::Internal::Type::Converter.inspect(item_type, depth: depth.succ)
  165. then: 0 else: 0 "#{self.class}[#{[items, nilable? ? 'nil' : nil].compact.join(' | ')}]"
  166. end
  167. end
  168. end
  169. end
  170. end

openai-ruby/lib/openai/internal/type/request_parameters.rb

93.33% lines covered

50.0% branches covered

15 relevant lines. 14 lines covered and 1 lines missed.
6 total branches, 3 branches covered and 3 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. 1 module RequestParameters
  7. # @!attribute request_options
  8. # Options to specify HTTP behaviour for this request.
  9. #
  10. # @return [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. # @param mod [Module]
  12. 1 def self.included(mod)
  13. 110 else: 110 then: 0 raise ArgumentError.new(mod) unless mod <= OpenAI::Internal::Type::BaseModel
  14. 110 mod.optional(:request_options, OpenAI::RequestOptions)
  15. end
  16. # @api private
  17. 1 module Converter
  18. # @api private
  19. #
  20. # @param params [Object]
  21. #
  22. # @return [Array(Object, Hash{Symbol=>Object})]
  23. 1 def dump_request(params)
  24. 2 state = {can_retry: true}
  25. case (dumped = dump(params, state: state))
  26. 2 in: 2 in Hash
  27. 2 options = OpenAI::Internal::Util.coerce_hash!(dumped[:request_options]).to_h
  28. 2 then: 2 else: 0 request_options = state.fetch(:can_retry) ? options : {**options, max_retries: 0}
  29. 2 [dumped.except(:request_options), request_options]
  30. else: 0 else
  31. [dumped, nil]
  32. end
  33. end
  34. end
  35. end
  36. end
  37. end
  38. end

openai-ruby/lib/openai/internal/type/union.rb

43.59% lines covered

18.42% branches covered

78 relevant lines. 34 lines covered and 44 lines missed.
38 total branches, 7 branches covered and 31 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. #
  7. # @example
  8. # # `chat_completion_content_part` is a `OpenAI::Chat::ChatCompletionContentPart`
  9. # case chat_completion_content_part
  10. # when OpenAI::Chat::ChatCompletionContentPartText
  11. # puts(chat_completion_content_part.text)
  12. # when OpenAI::Chat::ChatCompletionContentPartImage
  13. # puts(chat_completion_content_part.image_url)
  14. # when OpenAI::Chat::ChatCompletionContentPartInputAudio
  15. # puts(chat_completion_content_part.input_audio)
  16. # else
  17. # puts(chat_completion_content_part)
  18. # end
  19. #
  20. # @example
  21. # case chat_completion_content_part
  22. # in {type: :text, text: text}
  23. # puts(text)
  24. # in {type: :image_url, image_url: image_url}
  25. # puts(image_url)
  26. # in {type: :input_audio, input_audio: input_audio}
  27. # puts(input_audio)
  28. # else
  29. # puts(chat_completion_content_part)
  30. # end
  31. 1 module Union
  32. 1 include OpenAI::Internal::Type::Converter
  33. 1 include OpenAI::Internal::Util::SorbetRuntimeSupport
  34. # @api private
  35. #
  36. # All of the specified variant info for this union.
  37. #
  38. # @return [Array<Array(Symbol, Proc)>]
  39. 710 private def known_variants = (@known_variants ||= [])
  40. # @api private
  41. #
  42. # @return [Array<Array(Symbol, Object)>]
  43. 1 protected def derefed_variants
  44. known_variants.map { |key, variant_fn| [key, variant_fn.call] }
  45. end
  46. # All of the specified variants for this union.
  47. #
  48. # @return [Array<Object>]
  49. 1 def variants = derefed_variants.map(&:last)
  50. # @api private
  51. #
  52. # @param property [Symbol]
  53. 1 private def discriminator(property)
  54. else: 0 case property
  55. 73 in: 73 in Symbol
  56. 73 @discriminator = property
  57. end
  58. end
  59. # @api private
  60. #
  61. # @param key [Symbol, Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class]
  62. #
  63. # @param spec [Hash{Symbol=>Object}, Proc, OpenAI::Internal::Type::Converter, Class] .
  64. #
  65. # @option spec [NilClass, TrueClass, FalseClass, Integer, Float, Symbol] :const
  66. #
  67. # @option spec [Proc] :enum
  68. #
  69. # @option spec [Proc] :union
  70. #
  71. # @option spec [Boolean] :"nil?"
  72. 1 private def variant(key, spec = nil)
  73. variant_info =
  74. else: 0 case key
  75. 701 in: 338 in Symbol
  76. 338 [key, OpenAI::Internal::Type::Converter.type_info(spec)]
  77. in: 363 in Proc | OpenAI::Internal::Type::Converter | Class | Hash
  78. 363 [nil, OpenAI::Internal::Type::Converter.type_info(key)]
  79. end
  80. 701 known_variants << variant_info
  81. end
  82. # @api private
  83. #
  84. # @param value [Object]
  85. #
  86. # @return [OpenAI::Internal::Type::Converter, Class, nil]
  87. 1 private def resolve_variant(value)
  88. case [@discriminator, value]
  89. 6 in: 0 in [_, OpenAI::Internal::Type::BaseModel]
  90. value.class
  91. in: 0 in [Symbol, Hash]
  92. key = value.fetch(@discriminator) do
  93. value.fetch(@discriminator.to_s, OpenAI::Internal::OMIT)
  94. end
  95. then: 0 else: 0 return nil if key == OpenAI::Internal::OMIT
  96. then: 0 else: 0 key = key.to_sym if key.is_a?(String)
  97. then: 0 else: 0 then: 0 else: 0 known_variants.find { |k,| k == key }&.last&.call
  98. else: 6 else
  99. 6 nil
  100. end
  101. end
  102. # rubocop:disable Style/HashEachMethods
  103. # rubocop:disable Style/CaseEquality
  104. # @api public
  105. #
  106. # @param other [Object]
  107. #
  108. # @return [Boolean]
  109. 1 def ===(other)
  110. 2 known_variants.any? do |_, variant_fn|
  111. 38 variant_fn.call === other
  112. end
  113. end
  114. # @api public
  115. #
  116. # @param other [Object]
  117. #
  118. # @return [Boolean]
  119. 1 def ==(other)
  120. OpenAI::Internal::Type::Union === other && other.derefed_variants == derefed_variants
  121. end
  122. # @api public
  123. #
  124. # @return [Integer]
  125. 1 def hash = variants.hash
  126. # @api private
  127. #
  128. # Tries to efficiently coerce the given value to one of the known variants.
  129. #
  130. # If the value cannot match any of the known variants, the coercion is considered
  131. # non-viable and returns the original value.
  132. #
  133. # @param value [Object]
  134. #
  135. # @param state [Hash{Symbol=>Object}] .
  136. #
  137. # @option state [Boolean] :translate_names
  138. #
  139. # @option state [Boolean] :strictness
  140. #
  141. # @option state [Hash{Symbol=>Object}] :exactness
  142. #
  143. # @option state [Class<StandardError>] :error
  144. #
  145. # @option state [Integer] :branched
  146. #
  147. # @return [Object]
  148. 1 def coerce(value, state:)
  149. then: 0 else: 0 if (target = resolve_variant(value))
  150. return OpenAI::Internal::Type::Converter.coerce(target, value, state: state)
  151. end
  152. strictness = state.fetch(:strictness)
  153. exactness = state.fetch(:exactness)
  154. alternatives = []
  155. known_variants.each do |_, variant_fn|
  156. target = variant_fn.call
  157. exact = state[:exactness] = {yes: 0, no: 0, maybe: 0}
  158. state[:branched] += 1
  159. coerced = OpenAI::Internal::Type::Converter.coerce(target, value, state: state)
  160. yes, no, maybe = exact.values
  161. then: 0 if (no + maybe).zero? || (!strictness && yes.positive?)
  162. exact.each { exactness[_1] += _2 }
  163. state[:exactness] = exactness
  164. else: 0 return coerced
  165. then: 0 else: 0 elsif maybe.positive?
  166. alternatives << [[-yes, -maybe, no], exact, coerced]
  167. end
  168. end
  169. else: 0 case alternatives.sort_by!(&:first)
  170. in: 0 in []
  171. exactness[:no] += 1
  172. state[:error] = ArgumentError.new("no matching variant for #{value.inspect}")
  173. value
  174. in: 0 in [[_, exact, coerced], *]
  175. exact.each { exactness[_1] += _2 }
  176. coerced
  177. end
  178. .tap { state[:exactness] = exactness }
  179. ensure
  180. state[:strictness] = strictness
  181. end
  182. # @api private
  183. #
  184. # @param value [Object]
  185. #
  186. # @param state [Hash{Symbol=>Object}] .
  187. #
  188. # @option state [Boolean] :can_retry
  189. #
  190. # @return [Object]
  191. 1 def dump(value, state:)
  192. 6 then: 0 else: 6 if (target = resolve_variant(value))
  193. return OpenAI::Internal::Type::Converter.dump(target, value, state: state)
  194. end
  195. 6 known_variants.each do
  196. 10 target = _2.call
  197. 10 then: 2 else: 8 return OpenAI::Internal::Type::Converter.dump(target, value, state: state) if target === value
  198. end
  199. 4 super
  200. end
  201. # @api private
  202. #
  203. # @return [Object]
  204. 1 def to_sorbet_type
  205. types = variants.map { OpenAI::Internal::Util::SorbetRuntimeSupport.to_sorbet_type(_1) }.uniq
  206. case types
  207. in: 0 in []
  208. T.noreturn
  209. in: 0 in [type]
  210. type
  211. else: 0 else
  212. T.any(*types)
  213. end
  214. end
  215. # rubocop:enable Style/CaseEquality
  216. # rubocop:enable Style/HashEachMethods
  217. # @api private
  218. #
  219. # @param depth [Integer]
  220. #
  221. # @return [String]
  222. 1 def inspect(depth: 0)
  223. then: 0 else: 0 if depth.positive?
  224. then: 0 else: 0 return is_a?(Module) ? super() : self.class.name
  225. end
  226. members = variants.map { OpenAI::Internal::Type::Converter.inspect(_1, depth: depth.succ) }
  227. then: 0 else: 0 prefix = is_a?(Module) ? name : self.class.name
  228. "#{prefix}[#{members.join(' | ')}]"
  229. end
  230. end
  231. end
  232. end
  233. end

openai-ruby/lib/openai/internal/type/unknown.rb

80.0% lines covered

100.0% branches covered

15 relevant lines. 12 lines covered and 3 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. 1 module Type
  5. # @api private
  6. #
  7. # @abstract
  8. #
  9. # When we don't know what to expect for the value.
  10. 1 class Unknown
  11. 1 extend OpenAI::Internal::Type::Converter
  12. 1 extend OpenAI::Internal::Util::SorbetRuntimeSupport
  13. # rubocop:disable Lint/UnusedMethodArgument
  14. 1 private_class_method :new
  15. # @api public
  16. #
  17. # @param other [Object]
  18. #
  19. # @return [Boolean]
  20. 1 def self.===(other) = true
  21. # @api public
  22. #
  23. # @param other [Object]
  24. #
  25. # @return [Boolean]
  26. 1 def self.==(other) = other.is_a?(Class) && other <= OpenAI::Internal::Type::Unknown
  27. 1 class << self
  28. # @api private
  29. #
  30. # No coercion needed for Unknown type.
  31. #
  32. # @param value [Object]
  33. #
  34. # @param state [Hash{Symbol=>Object}] .
  35. #
  36. # @option state [Boolean] :translate_names
  37. #
  38. # @option state [Boolean] :strictness
  39. #
  40. # @option state [Hash{Symbol=>Object}] :exactness
  41. #
  42. # @option state [Class<StandardError>] :error
  43. #
  44. # @option state [Integer] :branched
  45. #
  46. # @return [Object]
  47. 1 def coerce(value, state:)
  48. state.fetch(:exactness)[:yes] += 1
  49. value
  50. end
  51. # @!method dump(value, state:)
  52. # @api private
  53. #
  54. # @param value [Object]
  55. #
  56. # @param state [Hash{Symbol=>Object}] .
  57. #
  58. # @option state [Boolean] :can_retry
  59. #
  60. # @return [Object]
  61. # @api private
  62. #
  63. # @return [Object]
  64. 1 def to_sorbet_type
  65. T.anything
  66. end
  67. end
  68. # rubocop:enable Lint/UnusedMethodArgument
  69. end
  70. end
  71. end
  72. end

openai-ruby/lib/openai/internal/util.rb

42.81% lines covered

22.56% branches covered

313 relevant lines. 134 lines covered and 179 lines missed.
164 total branches, 37 branches covered and 127 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Internal
  4. # @api private
  5. 1 module Util
  6. # @api private
  7. #
  8. # @return [Float]
  9. 1 def self.monotonic_secs = Process.clock_gettime(Process::CLOCK_MONOTONIC)
  10. # @api private
  11. #
  12. # @param ns [Module, Class]
  13. #
  14. # @return [Enumerable<Module, Class>]
  15. 1 def self.walk_namespaces(ns)
  16. 2774 ns.constants(false).lazy.flat_map do
  17. case (c = ns.const_get(_1, false))
  18. 4806 in: 2772 in Module | Class
  19. 2772 walk_namespaces(c)
  20. else: 2034 else
  21. 2034 []
  22. end
  23. end
  24. .chain([ns])
  25. end
  26. 1 class << self
  27. # @api private
  28. #
  29. # @return [String]
  30. 1 def arch
  31. then: 1 else: 0 case (arch = RbConfig::CONFIG["arch"])&.downcase
  32. 1 in: 0 in nil
  33. "unknown"
  34. in: 1 in /aarch64|arm64/
  35. 1 "arm64"
  36. in: 0 in /x86_64/
  37. "x64"
  38. in: 0 in /arm/
  39. "arm"
  40. else: 0 else
  41. "other:#{arch}"
  42. end
  43. end
  44. # @api private
  45. #
  46. # @return [String]
  47. 1 def os
  48. then: 1 else: 0 case (host = RbConfig::CONFIG["host_os"])&.downcase
  49. 1 in: 0 in nil
  50. "Unknown"
  51. in: 0 in /linux/
  52. "Linux"
  53. in: 1 in /darwin/
  54. 1 "MacOS"
  55. in: 0 in /freebsd/
  56. "FreeBSD"
  57. in: 0 in /openbsd/
  58. "OpenBSD"
  59. in: 0 in /mswin|mingw|cygwin|ucrt/
  60. "Windows"
  61. else: 0 else
  62. "Other:#{host}"
  63. end
  64. end
  65. end
  66. 1 class << self
  67. # @api private
  68. #
  69. # @param input [Object]
  70. #
  71. # @return [Boolean]
  72. 1 def primitive?(input)
  73. case input
  74. in: 0 in true | false | Numeric | Symbol | String
  75. true
  76. else: 0 else
  77. false
  78. end
  79. end
  80. # @api private
  81. #
  82. # @param input [String, Boolean]
  83. #
  84. # @return [Boolean, Object]
  85. 1 def coerce_boolean(input)
  86. then: 0 else: 2 case input.is_a?(String) ? input.downcase : input
  87. 2 in: 0 in "true"
  88. true
  89. in: 0 in "false"
  90. false
  91. else: 2 else
  92. 2 input
  93. end
  94. end
  95. # @api private
  96. #
  97. # @param input [String, Boolean]
  98. #
  99. # @raise [ArgumentError]
  100. # @return [Boolean, nil]
  101. 1 def coerce_boolean!(input)
  102. case coerce_boolean(input)
  103. in: 0 in true | false | nil => coerced
  104. coerced
  105. else: 0 else
  106. raise ArgumentError.new("Unable to coerce #{input.inspect} into boolean value")
  107. end
  108. end
  109. # @api private
  110. #
  111. # @param input [String, Integer]
  112. #
  113. # @return [Integer, Object]
  114. 1 def coerce_integer(input)
  115. Integer(input, exception: false) || input
  116. end
  117. # @api private
  118. #
  119. # @param input [String, Integer, Float]
  120. #
  121. # @return [Float, Object]
  122. 1 def coerce_float(input)
  123. Float(input, exception: false) || input
  124. end
  125. # @api private
  126. #
  127. # @param input [Object]
  128. #
  129. # @return [Hash{Object=>Object}, Object]
  130. 1 def coerce_hash(input)
  131. case input
  132. 4 in: 2 in NilClass | Array | Set | Enumerator | StringIO | IO
  133. 2 input
  134. else: 2 else
  135. 2 then: 2 else: 0 input.respond_to?(:to_h) ? input.to_h : input
  136. end
  137. end
  138. # @api private
  139. #
  140. # @param input [Object]
  141. #
  142. # @raise [ArgumentError]
  143. # @return [Hash{Object=>Object}, nil]
  144. 1 def coerce_hash!(input)
  145. case coerce_hash(input)
  146. 2 in: 2 in Hash | nil => coerced
  147. 2 coerced
  148. else: 0 else
  149. message = "Expected a #{Hash} or #{OpenAI::Internal::Type::BaseModel}, got #{data.inspect}"
  150. raise ArgumentError.new(message)
  151. end
  152. end
  153. end
  154. 1 class << self
  155. # @api private
  156. #
  157. # @param lhs [Object]
  158. # @param rhs [Object]
  159. # @param concat [Boolean]
  160. #
  161. # @return [Object]
  162. 1 private def deep_merge_lr(lhs, rhs, concat: false)
  163. case [lhs, rhs, concat]
  164. 6 in: 6 in [Hash, Hash, _]
  165. 6 lhs.merge(rhs) { deep_merge_lr(_2, _3, concat: concat) }
  166. in: 0 in [Array, Array, true]
  167. lhs.concat(rhs)
  168. else: 0 else
  169. rhs
  170. end
  171. end
  172. # @api private
  173. #
  174. # Recursively merge one hash with another. If the values at a given key are not
  175. # both hashes, just take the new value.
  176. #
  177. # @param values [Array<Object>]
  178. #
  179. # @param sentinel [Object, nil] the value to return if no values are provided.
  180. #
  181. # @param concat [Boolean] whether to merge sequences by concatenation.
  182. #
  183. # @return [Object]
  184. 1 def deep_merge(*values, sentinel: nil, concat: false)
  185. case values
  186. 6 in: 6 in [value, *values]
  187. 6 values.reduce(value) do |acc, val|
  188. 6 deep_merge_lr(acc, val, concat: concat)
  189. end
  190. else: 0 else
  191. sentinel
  192. end
  193. end
  194. # @api private
  195. #
  196. # @param data [Hash{Symbol=>Object}, Array<Object>, Object]
  197. # @param pick [Symbol, Integer, Array<Symbol, Integer>, Proc, nil]
  198. # @param blk [Proc, nil]
  199. #
  200. # @return [Object, nil]
  201. 1 def dig(data, pick, &blk)
  202. case [data, pick]
  203. 8 in: 0 in [_, nil]
  204. data
  205. in: 8 in [Hash, Symbol] | [Array, Integer]
  206. 16 then: 2 else: 6 data.fetch(pick) { blk&.call }
  207. in: 0 in [Hash | Array, Array]
  208. pick.reduce(data) do |acc, key|
  209. case acc
  210. in: 0 in Hash if acc.key?(key)
  211. acc.fetch(key)
  212. in: 0 in Array if key.is_a?(Integer) && key < acc.length
  213. acc[key]
  214. else: 0 else
  215. then: 0 else: 0 return blk&.call
  216. end
  217. end
  218. in: 0 in [_, Proc]
  219. pick.call(data)
  220. else: 0 else
  221. then: 0 else: 0 blk&.call
  222. end
  223. end
  224. end
  225. 1 class << self
  226. # @api private
  227. #
  228. # @param uri [URI::Generic]
  229. #
  230. # @return [String]
  231. 1 def uri_origin(uri)
  232. 2 then: 2 else: 0 "#{uri.scheme}://#{uri.host}#{uri.port == uri.default_port ? '' : ":#{uri.port}"}"
  233. end
  234. # @api private
  235. #
  236. # @param path [String, Array<String>]
  237. #
  238. # @return [String]
  239. 1 def interpolate_path(path)
  240. else: 0 case path
  241. 2 in: 2 in String
  242. 2 path
  243. in: 0 in []
  244. ""
  245. in: 0 in [String => p, *interpolations]
  246. encoded = interpolations.map { ERB::Util.url_encode(_1) }
  247. format(p, *encoded)
  248. end
  249. end
  250. end
  251. 1 class << self
  252. # @api private
  253. #
  254. # @param query [String, nil]
  255. #
  256. # @return [Hash{String=>Array<String>}]
  257. 1 def decode_query(query)
  258. 4 CGI.parse(query.to_s)
  259. end
  260. # @api private
  261. #
  262. # @param query [Hash{String=>Array<String>, String, nil}, nil]
  263. #
  264. # @return [String, nil]
  265. 1 def encode_query(query)
  266. 4 then: 4 else: 0 query.to_h.empty? ? nil : URI.encode_www_form(query)
  267. end
  268. end
  269. 1 class << self
  270. # @api private
  271. #
  272. # @param url [URI::Generic, String]
  273. #
  274. # @return [Hash{Symbol=>String, Integer, nil}]
  275. 1 def parse_uri(url)
  276. 4 parsed = URI::Generic.component.zip(URI.split(url)).to_h
  277. 4 {**parsed, query: decode_query(parsed.fetch(:query))}
  278. end
  279. # @api private
  280. #
  281. # @param parsed [Hash{Symbol=>String, Integer, nil}] .
  282. #
  283. # @option parsed [String, nil] :scheme
  284. #
  285. # @option parsed [String, nil] :host
  286. #
  287. # @option parsed [Integer, nil] :port
  288. #
  289. # @option parsed [String, nil] :path
  290. #
  291. # @option parsed [Hash{String=>Array<String>}] :query
  292. #
  293. # @return [URI::Generic]
  294. 1 def unparse_uri(parsed)
  295. 2 URI::Generic.build(**parsed, query: encode_query(parsed.fetch(:query)))
  296. end
  297. # @api private
  298. #
  299. # @param lhs [Hash{Symbol=>String, Integer, nil}] .
  300. #
  301. # @option lhs [String, nil] :scheme
  302. #
  303. # @option lhs [String, nil] :host
  304. #
  305. # @option lhs [Integer, nil] :port
  306. #
  307. # @option lhs [String, nil] :path
  308. #
  309. # @option lhs [Hash{String=>Array<String>}] :query
  310. #
  311. # @param rhs [Hash{Symbol=>String, Integer, nil}] .
  312. #
  313. # @option rhs [String, nil] :scheme
  314. #
  315. # @option rhs [String, nil] :host
  316. #
  317. # @option rhs [Integer, nil] :port
  318. #
  319. # @option rhs [String, nil] :path
  320. #
  321. # @option rhs [Hash{String=>Array<String>}] :query
  322. #
  323. # @return [URI::Generic]
  324. 1 def join_parsed_uri(lhs, rhs)
  325. 2 base_path, base_query = lhs.fetch_values(:path, :query)
  326. 2 then: 0 else: 2 slashed = base_path.end_with?("/") ? base_path : "#{base_path}/"
  327. 2 parsed_path, parsed_query = parse_uri(rhs.fetch(:path)).fetch_values(:path, :query)
  328. 2 override = URI::Generic.build(**rhs.slice(:scheme, :host, :port), path: parsed_path)
  329. 2 joined = URI.join(URI::Generic.build(lhs.except(:path, :query)), slashed, override)
  330. 2 query = deep_merge(
  331. 2 then: 0 else: 2 joined.path == base_path ? base_query : {},
  332. parsed_query,
  333. rhs[:query].to_h,
  334. concat: true
  335. )
  336. 2 joined.query = encode_query(query)
  337. 2 joined
  338. end
  339. end
  340. 1 class << self
  341. # @api private
  342. #
  343. # @param headers [Hash{String=>String, Integer, Array<String, Integer, nil>, nil}]
  344. #
  345. # @return [Hash{String=>String}]
  346. 1 def normalized_headers(*headers)
  347. 4 {}.merge(*headers.compact).to_h do |key, val|
  348. value =
  349. case val
  350. 42 in: 0 in Array
  351. then: 0 else: 0 then: 0 else: 0 val.filter_map { _1&.to_s&.strip }.join(", ")
  352. else: 42 else
  353. 42 then: 34 else: 8 then: 34 else: 8 val&.to_s&.strip
  354. end
  355. 42 [key.downcase, value]
  356. end
  357. end
  358. end
  359. # @api private
  360. #
  361. # An adapter that satisfies the IO interface required by `::IO.copy_stream`
  362. 1 class ReadIOAdapter
  363. # @api private
  364. #
  365. # @return [Boolean, nil]
  366. 1 def close? = @closing
  367. # @api private
  368. 1 def close
  369. case @stream
  370. 2 in: 0 in Enumerator
  371. OpenAI::Internal::Util.close_fused!(@stream)
  372. in: 0 in IO if close?
  373. else: 2 @stream.close
  374. else
  375. end
  376. end
  377. # @api private
  378. #
  379. # @param max_len [Integer, nil]
  380. #
  381. # @return [String]
  382. 1 private def read_enum(max_len)
  383. else: 0 case max_len
  384. in: 0 in nil
  385. @stream.to_a.join
  386. in: 0 in Integer
  387. body: 0 @buf << @stream.next while @buf.length < max_len
  388. @buf.slice!(..max_len)
  389. end
  390. rescue StopIteration
  391. @stream = nil
  392. @buf.slice!(0..)
  393. end
  394. # @api private
  395. #
  396. # @param max_len [Integer, nil]
  397. # @param out_string [String, nil]
  398. #
  399. # @return [String, nil]
  400. 1 def read(max_len = nil, out_string = nil)
  401. else: 0 case @stream
  402. 4 in: 0 in nil
  403. nil
  404. in: 4 in IO | StringIO
  405. 4 @stream.read(max_len, out_string)
  406. in: 0 in Enumerator
  407. read = read_enum(max_len)
  408. else: 0 case out_string
  409. in: 0 in String
  410. out_string.replace(read)
  411. in: 0 in nil
  412. read
  413. end
  414. end
  415. .tap(&@blk)
  416. end
  417. # @api private
  418. #
  419. # @param src [String, Pathname, StringIO, Enumerable<String>]
  420. # @param blk [Proc]
  421. #
  422. # @yieldparam [String]
  423. 1 def initialize(src, &blk)
  424. @stream =
  425. case src
  426. 2 in: 2 in String
  427. 2 StringIO.new(src)
  428. in: 0 in Pathname
  429. @closing = true
  430. src.open(binmode: true)
  431. else: 0 else
  432. src
  433. end
  434. 2 @buf = String.new
  435. 2 @blk = blk
  436. end
  437. end
  438. 1 class << self
  439. # @param blk [Proc]
  440. #
  441. # @yieldparam [Enumerator::Yielder]
  442. # @return [Enumerable<String>]
  443. 1 def writable_enum(&blk)
  444. Enumerator.new do |y|
  445. buf = String.new
  446. y.define_singleton_method(:write) do
  447. self << buf.replace(_1)
  448. buf.bytesize
  449. end
  450. blk.call(y)
  451. end
  452. end
  453. end
  454. # @type [Regexp]
  455. 1 JSON_CONTENT = %r{^application/(?:vnd(?:\.[^.]+)*\+)?json(?!l)}
  456. # @type [Regexp]
  457. 1 JSONL_CONTENT = %r{^application/(:?x-(?:n|l)djson)|(:?(?:x-)?jsonl)}
  458. 1 class << self
  459. # @api private
  460. #
  461. # @param y [Enumerator::Yielder]
  462. # @param val [Object]
  463. # @param closing [Array<Proc>]
  464. # @param content_type [String, nil]
  465. 1 private def write_multipart_content(y, val:, closing:, content_type: nil)
  466. content_line = "Content-Type: %s\r\n\r\n"
  467. case val
  468. in: 0 in OpenAI::FilePart
  469. return write_multipart_content(
  470. y,
  471. val: val.content,
  472. closing: closing,
  473. content_type: val.content_type
  474. )
  475. in: 0 in Pathname
  476. y << format(content_line, content_type || "application/octet-stream")
  477. io = val.open(binmode: true)
  478. closing << io.method(:close)
  479. IO.copy_stream(io, y)
  480. in: 0 in IO
  481. y << format(content_line, content_type || "application/octet-stream")
  482. IO.copy_stream(val, y)
  483. in: 0 in StringIO
  484. y << format(content_line, content_type || "application/octet-stream")
  485. y << val.string
  486. in: 0 in -> { primitive?(_1) }
  487. y << format(content_line, content_type || "text/plain")
  488. y << val.to_s
  489. else: 0 else
  490. y << format(content_line, content_type || "application/json")
  491. y << JSON.generate(val)
  492. end
  493. y << "\r\n"
  494. end
  495. # @api private
  496. #
  497. # @param y [Enumerator::Yielder]
  498. # @param boundary [String]
  499. # @param key [Symbol, String]
  500. # @param val [Object]
  501. # @param closing [Array<Proc>]
  502. 1 private def write_multipart_chunk(y, boundary:, key:, val:, closing:)
  503. y << "--#{boundary}\r\n"
  504. y << "Content-Disposition: form-data"
  505. else: 0 then: 0 unless key.nil?
  506. name = ERB::Util.url_encode(key.to_s)
  507. y << "; name=\"#{name}\""
  508. end
  509. case val
  510. in: 0 in OpenAI::FilePart unless val.filename.nil?
  511. filename = ERB::Util.url_encode(val.filename)
  512. y << "; filename=\"#{filename}\""
  513. in: 0 in Pathname | IO
  514. filename = ERB::Util.url_encode(::File.basename(val.to_path))
  515. else: 0 y << "; filename=\"#{filename}\""
  516. else
  517. end
  518. y << "\r\n"
  519. write_multipart_content(y, val: val, closing: closing)
  520. end
  521. # @api private
  522. #
  523. # https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.1.md#special-considerations-for-multipart-content
  524. #
  525. # @param body [Object]
  526. #
  527. # @return [Array(String, Enumerable<String>)]
  528. 1 private def encode_multipart_streaming(body)
  529. boundary = SecureRandom.urlsafe_base64(60)
  530. closing = []
  531. strio = writable_enum do |y|
  532. case body
  533. in: 0 in Hash
  534. body.each do |key, val|
  535. case val
  536. in: 0 in Array if val.all? { primitive?(_1) }
  537. val.each do |v|
  538. write_multipart_chunk(y, boundary: boundary, key: key, val: v, closing: closing)
  539. end
  540. else: 0 else
  541. write_multipart_chunk(y, boundary: boundary, key: key, val: val, closing: closing)
  542. end
  543. end
  544. else: 0 else
  545. write_multipart_chunk(y, boundary: boundary, key: nil, val: body, closing: closing)
  546. end
  547. y << "--#{boundary}--\r\n"
  548. end
  549. fused_io = fused_enum(strio) { closing.each(&:call) }
  550. [boundary, fused_io]
  551. end
  552. # @api private
  553. #
  554. # @param headers [Hash{String=>String}]
  555. # @param body [Object]
  556. #
  557. # @return [Object]
  558. 1 def encode_content(headers, body)
  559. # rubocop:disable Style/CaseEquality
  560. # rubocop:disable Layout/LineLength
  561. 2 content_type = headers["content-type"]
  562. case [content_type, body]
  563. 2 in: 2 in [OpenAI::Internal::Util::JSON_CONTENT, Hash | Array | -> { primitive?(_1) }]
  564. 2 [headers, JSON.generate(body)]
  565. in: 0 in [OpenAI::Internal::Util::JSONL_CONTENT, Enumerable] unless OpenAI::Internal::Type::FileInput === body
  566. [headers, body.lazy.map { JSON.generate(_1) }]
  567. in: 0 in [%r{^multipart/form-data}, Hash | OpenAI::Internal::Type::FileInput]
  568. boundary, strio = encode_multipart_streaming(body)
  569. headers = {**headers, "content-type" => "#{content_type}; boundary=#{boundary}"}
  570. [headers, strio]
  571. in: 0 in [_, Symbol | Numeric]
  572. [headers, body.to_s]
  573. in: 0 in [_, StringIO]
  574. [headers, body.string]
  575. in: 0 in [_, OpenAI::FilePart]
  576. [headers, body.content]
  577. else: 0 else
  578. [headers, body]
  579. end
  580. # rubocop:enable Layout/LineLength
  581. # rubocop:enable Style/CaseEquality
  582. end
  583. # @api private
  584. #
  585. # https://www.iana.org/assignments/character-sets/character-sets.xhtml
  586. #
  587. # @param content_type [String]
  588. # @param text [String]
  589. 1 def force_charset!(content_type, text:)
  590. then: 0 else: 0 then: 0 else: 0 charset = /charset=([^;\s]+)/.match(content_type)&.captures&.first
  591. else: 0 then: 0 return unless charset
  592. begin
  593. encoding = Encoding.find(charset)
  594. text.force_encoding(encoding)
  595. rescue ArgumentError
  596. nil
  597. end
  598. end
  599. # @api private
  600. #
  601. # Assumes each chunk in stream has `Encoding::BINARY`.
  602. #
  603. # @param headers [Hash{String=>String}, Net::HTTPHeader]
  604. # @param stream [Enumerable<String>]
  605. # @param suppress_error [Boolean]
  606. #
  607. # @raise [JSON::ParserError]
  608. # @return [Object]
  609. 1 def decode_content(headers, stream:, suppress_error: false)
  610. case (content_type = headers["content-type"])
  611. 2 in: 2 in OpenAI::Internal::Util::JSON_CONTENT
  612. 2 json = stream.to_a.join
  613. begin
  614. 2 JSON.parse(json, symbolize_names: true)
  615. rescue JSON::ParserError => e
  616. else: 0 then: 0 raise e unless suppress_error
  617. json
  618. end
  619. in: 0 in OpenAI::Internal::Util::JSONL_CONTENT
  620. lines = decode_lines(stream)
  621. chain_fused(lines) do |y|
  622. lines.each { y << JSON.parse(_1, symbolize_names: true) }
  623. end
  624. in: 0 in %r{^text/event-stream}
  625. lines = decode_lines(stream)
  626. decode_sse(lines)
  627. else: 0 else
  628. text = stream.to_a.join
  629. force_charset!(content_type, text: text)
  630. StringIO.new(text)
  631. end
  632. end
  633. end
  634. 1 class << self
  635. # @api private
  636. #
  637. # https://doc.rust-lang.org/std/iter/trait.FusedIterator.html
  638. #
  639. # @param enum [Enumerable<Object>]
  640. # @param external [Boolean]
  641. # @param close [Proc]
  642. #
  643. # @return [Enumerable<Object>]
  644. 1 def fused_enum(enum, external: false, &close)
  645. 2 fused = false
  646. 2 iter = Enumerator.new do |y|
  647. 4 then: 2 else: 2 next if fused
  648. 2 fused = true
  649. 2 then: 2 if external
  650. 6 loop { y << enum.next }
  651. else: 0 else
  652. enum.each(&y)
  653. end
  654. ensure
  655. 4 then: 2 else: 2 close&.call
  656. 4 close = nil
  657. end
  658. 2 iter.define_singleton_method(:rewind) do
  659. fused = true
  660. self
  661. end
  662. 2 iter
  663. end
  664. # @api private
  665. #
  666. # @param enum [Enumerable<Object>, nil]
  667. 1 def close_fused!(enum)
  668. else: 0 then: 0 return unless enum.is_a?(Enumerator)
  669. # rubocop:disable Lint/UnreachableLoop
  670. enum.rewind.each { break }
  671. # rubocop:enable Lint/UnreachableLoop
  672. end
  673. # @api private
  674. #
  675. # @param enum [Enumerable<Object>, nil]
  676. # @param blk [Proc]
  677. #
  678. # @yieldparam [Enumerator::Yielder]
  679. # @return [Enumerable<Object>]
  680. 1 def chain_fused(enum, &blk)
  681. iter = Enumerator.new { blk.call(_1) }
  682. fused_enum(iter) { close_fused!(enum) }
  683. end
  684. end
  685. 1 class << self
  686. # @api private
  687. #
  688. # Assumes Strings have been forced into having `Encoding::BINARY`.
  689. #
  690. # This decoder is responsible for reassembling lines split across multiple
  691. # fragments.
  692. #
  693. # @param enum [Enumerable<String>]
  694. #
  695. # @return [Enumerable<String>]
  696. 1 def decode_lines(enum)
  697. re = /(\r\n|\r|\n)/
  698. buffer = String.new
  699. cr_seen = nil
  700. chain_fused(enum) do |y|
  701. enum.each do |row|
  702. offset = buffer.bytesize
  703. buffer << row
  704. body: 0 then: 0 else: 0 while (match = re.match(buffer, cr_seen&.to_i || offset))
  705. case [match.captures.first, cr_seen]
  706. in: 0 in ["\r", nil]
  707. cr_seen = match.end(1)
  708. next
  709. in: 0 in ["\r" | "\r\n", Integer]
  710. y << buffer.slice!(..(cr_seen.pred))
  711. else: 0 else
  712. y << buffer.slice!(..(match.end(1).pred))
  713. end
  714. offset = 0
  715. cr_seen = nil
  716. end
  717. end
  718. else: 0 then: 0 y << buffer.slice!(..(cr_seen.pred)) unless cr_seen.nil?
  719. else: 0 then: 0 y << buffer unless buffer.empty?
  720. end
  721. end
  722. # @api private
  723. #
  724. # https://html.spec.whatwg.org/multipage/server-sent-events.html#parsing-an-event-stream
  725. #
  726. # Assumes that `lines` has been decoded with `#decode_lines`.
  727. #
  728. # @param lines [Enumerable<String>]
  729. #
  730. # @return [Enumerable<Hash{Symbol=>Object}>]
  731. 1 def decode_sse(lines)
  732. # rubocop:disable Metrics/BlockLength
  733. chain_fused(lines) do |y|
  734. blank = {event: nil, data: nil, id: nil, retry: nil}
  735. current = {}
  736. lines.each do |line|
  737. case line.sub(/\R$/, "")
  738. in: 0 in ""
  739. then: 0 else: 0 next if current.empty?
  740. y << {**blank, **current}
  741. current = {}
  742. in: 0 in /^:/
  743. next
  744. in: 0 in /^([^:]+):\s?(.*)$/
  745. field, value = Regexp.last_match.captures
  746. case field
  747. in: 0 in "event"
  748. current.merge!(event: value)
  749. in: 0 in "data"
  750. (current[:data] ||= String.new) << (value << "\n")
  751. in: 0 in "id" unless value.include?("\0")
  752. current.merge!(id: value)
  753. in: 0 in "retry" if /^\d+$/ =~ value
  754. else: 0 current.merge!(retry: Integer(value))
  755. else
  756. else: 0 end
  757. else
  758. end
  759. end
  760. # rubocop:enable Metrics/BlockLength
  761. else: 0 then: 0 y << {**blank, **current} unless current.empty?
  762. end
  763. end
  764. end
  765. # @api private
  766. 1 module SorbetRuntimeSupport
  767. 1 class MissingSorbetRuntimeError < ::RuntimeError
  768. end
  769. # @api private
  770. #
  771. # @return [Hash{Symbol=>Object}]
  772. 1 private def sorbet_runtime_constants = @sorbet_runtime_constants ||= {}
  773. # @api private
  774. #
  775. # @param name [Symbol]
  776. 1 def const_missing(name)
  777. else: 0 then: 0 super unless sorbet_runtime_constants.key?(name)
  778. else: 0 then: 0 unless Object.const_defined?(:T)
  779. message = "Trying to access a Sorbet constant #{name.inspect} without `sorbet-runtime`."
  780. raise MissingSorbetRuntimeError.new(message)
  781. end
  782. sorbet_runtime_constants.fetch(name).call
  783. end
  784. # @api private
  785. #
  786. # @param name [Symbol]
  787. #
  788. # @return [Boolean]
  789. 1 def sorbet_constant_defined?(name) = sorbet_runtime_constants.key?(name)
  790. # @api private
  791. #
  792. # @param name [Symbol]
  793. # @param blk [Proc]
  794. 1 def define_sorbet_constant!(name, &blk) = sorbet_runtime_constants.store(name, blk)
  795. # @api private
  796. #
  797. # @return [Object]
  798. 1 def to_sorbet_type = raise NotImplementedError
  799. 1 class << self
  800. # @api private
  801. #
  802. # @param type [OpenAI::Internal::Util::SorbetRuntimeSupport, Object]
  803. #
  804. # @return [Object]
  805. 1 def to_sorbet_type(type)
  806. case type
  807. in: 0 in OpenAI::Internal::Util::SorbetRuntimeSupport
  808. type.to_sorbet_type
  809. in: 0 in Class | Module
  810. type
  811. in: 0 in true | false
  812. T::Boolean
  813. else: 0 else
  814. type.class
  815. end
  816. end
  817. end
  818. end
  819. 1 extend OpenAI::Internal::Util::SorbetRuntimeSupport
  820. 1 define_sorbet_constant!(:ParsedUri) do
  821. T.type_alias do
  822. {
  823. scheme: T.nilable(String),
  824. host: T.nilable(String),
  825. port: T.nilable(Integer),
  826. path: T.nilable(String),
  827. query: T::Hash[String, T::Array[String]]
  828. }
  829. end
  830. end
  831. 1 define_sorbet_constant!(:ServerSentEvent) do
  832. T.type_alias do
  833. {
  834. event: T.nilable(String),
  835. data: T.nilable(String),
  836. id: T.nilable(String),
  837. retry: T.nilable(Integer)
  838. }
  839. end
  840. end
  841. end
  842. end
  843. end

openai-ruby/lib/openai/models.rb

95.12% lines covered

66.67% branches covered

123 relevant lines. 117 lines covered and 6 lines missed.
9 total branches, 6 branches covered and 3 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 [OpenAI::Internal::Type::BaseModel, *OpenAI::Internal::Type::BaseModel.subclasses].each do |cls|
  4. 789 cls.define_sorbet_constant!(:OrHash) { T.type_alias { T.any(cls, OpenAI::Internal::AnyHash) } }
  5. end
  6. 1 OpenAI::Internal::Util.walk_namespaces(OpenAI::Models).each do |mod|
  7. case mod
  8. 1387 in: 483 in OpenAI::Internal::Type::Enum | OpenAI::Internal::Type::Union
  9. 483 mod.constants.each do |name|
  10. case mod.const_get(name)
  11. 1229 in: 0 in true | false
  12. mod.define_sorbet_constant!(:TaggedBoolean) { T.type_alias { T::Boolean } }
  13. mod.define_sorbet_constant!(:OrBoolean) { T.type_alias { T::Boolean } }
  14. in: 0 in Integer
  15. mod.define_sorbet_constant!(:TaggedInteger) { T.type_alias { Integer } }
  16. mod.define_sorbet_constant!(:OrInteger) { T.type_alias { Integer } }
  17. in: 0 in Float
  18. mod.define_sorbet_constant!(:TaggedFloat) { T.type_alias { Float } }
  19. mod.define_sorbet_constant!(:OrFloat) { T.type_alias { Float } }
  20. in: 972 in Symbol
  21. 972 mod.define_sorbet_constant!(:TaggedSymbol) { T.type_alias { Symbol } }
  22. 972 else: 257 mod.define_sorbet_constant!(:OrSymbol) { T.type_alias { T.any(Symbol, String) } }
  23. else
  24. end
  25. else: 904 end
  26. else
  27. end
  28. end
  29. 1 OpenAI::Internal::Util.walk_namespaces(OpenAI::Models)
  30. .lazy
  31. .grep(OpenAI::Internal::Type::Union)
  32. .each do |mod|
  33. 204 const = :Variants
  34. 204 then: 26 else: 178 next if mod.sorbet_constant_defined?(const)
  35. 178 mod.define_sorbet_constant!(const) { T.type_alias { mod.to_sorbet_type } }
  36. end
  37. 1 AllModels = OpenAI::Models::AllModels
  38. 1 Audio = OpenAI::Models::Audio
  39. 1 AudioModel = OpenAI::Models::AudioModel
  40. 1 AudioResponseFormat = OpenAI::Models::AudioResponseFormat
  41. 1 AutoFileChunkingStrategyParam = OpenAI::Models::AutoFileChunkingStrategyParam
  42. 1 Batch = OpenAI::Models::Batch
  43. 1 BatchCancelParams = OpenAI::Models::BatchCancelParams
  44. 1 BatchCreateParams = OpenAI::Models::BatchCreateParams
  45. 1 BatchError = OpenAI::Models::BatchError
  46. 1 BatchListParams = OpenAI::Models::BatchListParams
  47. 1 BatchRequestCounts = OpenAI::Models::BatchRequestCounts
  48. 1 BatchRetrieveParams = OpenAI::Models::BatchRetrieveParams
  49. 1 Beta = OpenAI::Models::Beta
  50. 1 Chat = OpenAI::Models::Chat
  51. 1 ChatModel = OpenAI::Models::ChatModel
  52. 1 ComparisonFilter = OpenAI::Models::ComparisonFilter
  53. 1 Completion = OpenAI::Models::Completion
  54. 1 CompletionChoice = OpenAI::Models::CompletionChoice
  55. 1 CompletionCreateParams = OpenAI::Models::CompletionCreateParams
  56. 1 CompletionUsage = OpenAI::Models::CompletionUsage
  57. 1 CompoundFilter = OpenAI::Models::CompoundFilter
  58. 1 ContainerCreateParams = OpenAI::Models::ContainerCreateParams
  59. 1 ContainerDeleteParams = OpenAI::Models::ContainerDeleteParams
  60. 1 ContainerListParams = OpenAI::Models::ContainerListParams
  61. 1 ContainerRetrieveParams = OpenAI::Models::ContainerRetrieveParams
  62. 1 Containers = OpenAI::Models::Containers
  63. 1 CreateEmbeddingResponse = OpenAI::Models::CreateEmbeddingResponse
  64. 1 Embedding = OpenAI::Models::Embedding
  65. 1 EmbeddingCreateParams = OpenAI::Models::EmbeddingCreateParams
  66. 1 EmbeddingModel = OpenAI::Models::EmbeddingModel
  67. 1 ErrorObject = OpenAI::Models::ErrorObject
  68. 1 EvalCreateParams = OpenAI::Models::EvalCreateParams
  69. 1 EvalCustomDataSourceConfig = OpenAI::Models::EvalCustomDataSourceConfig
  70. 1 EvalDeleteParams = OpenAI::Models::EvalDeleteParams
  71. 1 EvalListParams = OpenAI::Models::EvalListParams
  72. 1 EvalRetrieveParams = OpenAI::Models::EvalRetrieveParams
  73. 1 Evals = OpenAI::Models::Evals
  74. 1 EvalStoredCompletionsDataSourceConfig = OpenAI::Models::EvalStoredCompletionsDataSourceConfig
  75. 1 EvalUpdateParams = OpenAI::Models::EvalUpdateParams
  76. 1 FileChunkingStrategy = OpenAI::Models::FileChunkingStrategy
  77. 1 FileChunkingStrategyParam = OpenAI::Models::FileChunkingStrategyParam
  78. 1 FileContent = OpenAI::Models::FileContent
  79. 1 FileContentParams = OpenAI::Models::FileContentParams
  80. 1 FileCreateParams = OpenAI::Models::FileCreateParams
  81. 1 FileDeleted = OpenAI::Models::FileDeleted
  82. 1 FileDeleteParams = OpenAI::Models::FileDeleteParams
  83. 1 FileListParams = OpenAI::Models::FileListParams
  84. 1 FileObject = OpenAI::Models::FileObject
  85. 1 FilePurpose = OpenAI::Models::FilePurpose
  86. 1 FileRetrieveParams = OpenAI::Models::FileRetrieveParams
  87. 1 FineTuning = OpenAI::Models::FineTuning
  88. 1 FunctionDefinition = OpenAI::Models::FunctionDefinition
  89. # @type [OpenAI::Internal::Type::Converter]
  90. 1 FunctionParameters = OpenAI::Models::FunctionParameters
  91. 1 Graders = OpenAI::Models::Graders
  92. 1 Image = OpenAI::Models::Image
  93. 1 ImageCreateVariationParams = OpenAI::Models::ImageCreateVariationParams
  94. 1 ImageEditCompletedEvent = OpenAI::Models::ImageEditCompletedEvent
  95. 1 ImageEditParams = OpenAI::Models::ImageEditParams
  96. 1 ImageEditPartialImageEvent = OpenAI::Models::ImageEditPartialImageEvent
  97. 1 ImageEditStreamEvent = OpenAI::Models::ImageEditStreamEvent
  98. 1 ImageGenCompletedEvent = OpenAI::Models::ImageGenCompletedEvent
  99. 1 ImageGenerateParams = OpenAI::Models::ImageGenerateParams
  100. 1 ImageGenPartialImageEvent = OpenAI::Models::ImageGenPartialImageEvent
  101. 1 ImageGenStreamEvent = OpenAI::Models::ImageGenStreamEvent
  102. 1 ImageModel = OpenAI::Models::ImageModel
  103. 1 ImagesResponse = OpenAI::Models::ImagesResponse
  104. # @type [OpenAI::Internal::Type::Converter]
  105. 1 Metadata = OpenAI::Models::Metadata
  106. 1 Model = OpenAI::Models::Model
  107. 1 ModelDeleted = OpenAI::Models::ModelDeleted
  108. 1 ModelDeleteParams = OpenAI::Models::ModelDeleteParams
  109. 1 ModelListParams = OpenAI::Models::ModelListParams
  110. 1 ModelRetrieveParams = OpenAI::Models::ModelRetrieveParams
  111. 1 Moderation = OpenAI::Models::Moderation
  112. 1 ModerationCreateParams = OpenAI::Models::ModerationCreateParams
  113. 1 ModerationImageURLInput = OpenAI::Models::ModerationImageURLInput
  114. 1 ModerationModel = OpenAI::Models::ModerationModel
  115. 1 ModerationMultiModalInput = OpenAI::Models::ModerationMultiModalInput
  116. 1 ModerationTextInput = OpenAI::Models::ModerationTextInput
  117. 1 OtherFileChunkingStrategyObject = OpenAI::Models::OtherFileChunkingStrategyObject
  118. 1 Reasoning = OpenAI::Models::Reasoning
  119. 1 ReasoningEffort = OpenAI::Models::ReasoningEffort
  120. 1 ResponseFormatJSONObject = OpenAI::Models::ResponseFormatJSONObject
  121. 1 ResponseFormatJSONSchema = OpenAI::Models::ResponseFormatJSONSchema
  122. 1 ResponseFormatText = OpenAI::Models::ResponseFormatText
  123. 1 Responses = OpenAI::Models::Responses
  124. 1 ResponsesModel = OpenAI::Models::ResponsesModel
  125. 1 StaticFileChunkingStrategy = OpenAI::Models::StaticFileChunkingStrategy
  126. 1 StaticFileChunkingStrategyObject = OpenAI::Models::StaticFileChunkingStrategyObject
  127. 1 StaticFileChunkingStrategyObjectParam = OpenAI::Models::StaticFileChunkingStrategyObjectParam
  128. 1 Upload = OpenAI::Models::Upload
  129. 1 UploadCancelParams = OpenAI::Models::UploadCancelParams
  130. 1 UploadCompleteParams = OpenAI::Models::UploadCompleteParams
  131. 1 UploadCreateParams = OpenAI::Models::UploadCreateParams
  132. 1 Uploads = OpenAI::Models::Uploads
  133. 1 VectorStore = OpenAI::Models::VectorStore
  134. 1 VectorStoreCreateParams = OpenAI::Models::VectorStoreCreateParams
  135. 1 VectorStoreDeleted = OpenAI::Models::VectorStoreDeleted
  136. 1 VectorStoreDeleteParams = OpenAI::Models::VectorStoreDeleteParams
  137. 1 VectorStoreListParams = OpenAI::Models::VectorStoreListParams
  138. 1 VectorStoreRetrieveParams = OpenAI::Models::VectorStoreRetrieveParams
  139. 1 VectorStores = OpenAI::Models::VectorStores
  140. 1 VectorStoreSearchParams = OpenAI::Models::VectorStoreSearchParams
  141. 1 VectorStoreUpdateParams = OpenAI::Models::VectorStoreUpdateParams
  142. 1 Webhooks = OpenAI::Models::Webhooks
  143. end

openai-ruby/lib/openai/models/all_models.rb

100.0% lines covered

100.0% branches covered

19 relevant lines. 19 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module AllModels
  5. 1 extend OpenAI::Internal::Type::Union
  6. 1 variant String
  7. 1 variant enum: -> { OpenAI::ChatModel }
  8. 1 variant enum: -> { OpenAI::AllModels::ResponsesOnlyModel }
  9. 1 module ResponsesOnlyModel
  10. 1 extend OpenAI::Internal::Type::Enum
  11. 1 O1_PRO = :"o1-pro"
  12. 1 O1_PRO_2025_03_19 = :"o1-pro-2025-03-19"
  13. 1 O3_PRO = :"o3-pro"
  14. 1 O3_PRO_2025_06_10 = :"o3-pro-2025-06-10"
  15. 1 O3_DEEP_RESEARCH = :"o3-deep-research"
  16. 1 O3_DEEP_RESEARCH_2025_06_26 = :"o3-deep-research-2025-06-26"
  17. 1 O4_MINI_DEEP_RESEARCH = :"o4-mini-deep-research"
  18. 1 O4_MINI_DEEP_RESEARCH_2025_06_26 = :"o4-mini-deep-research-2025-06-26"
  19. 1 COMPUTER_USE_PREVIEW = :"computer-use-preview"
  20. 1 COMPUTER_USE_PREVIEW_2025_03_11 = :"computer-use-preview-2025-03-11"
  21. # @!method self.values
  22. # @return [Array<Symbol>]
  23. end
  24. # @!method self.variants
  25. # @return [Array(String, Symbol, OpenAI::Models::ChatModel, Symbol, OpenAI::Models::AllModels::ResponsesOnlyModel)]
  26. end
  27. end
  28. end

openai-ruby/lib/openai/models/audio/speech_create_params.rb

98.0% lines covered

100.0% branches covered

50 relevant lines. 49 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. # @see OpenAI::Resources::Audio::Speech#create
  6. 1 class SpeechCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute input
  10. # The text to generate audio for. The maximum length is 4096 characters.
  11. #
  12. # @return [String]
  13. 1 required :input, String
  14. # @!attribute model
  15. # One of the available [TTS models](https://platform.openai.com/docs/models#tts):
  16. # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
  17. #
  18. # @return [String, Symbol, OpenAI::Models::Audio::SpeechModel]
  19. 1 required :model, union: -> { OpenAI::Audio::SpeechCreateParams::Model }
  20. # @!attribute voice
  21. # The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
  22. # `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
  23. # `verse`. Previews of the voices are available in the
  24. # [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
  25. #
  26. # @return [String, Symbol, OpenAI::Models::Audio::SpeechCreateParams::Voice]
  27. 1 required :voice, union: -> { OpenAI::Audio::SpeechCreateParams::Voice }
  28. # @!attribute instructions
  29. # Control the voice of your generated audio with additional instructions. Does not
  30. # work with `tts-1` or `tts-1-hd`.
  31. #
  32. # @return [String, nil]
  33. 1 optional :instructions, String
  34. # @!attribute response_format
  35. # The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
  36. # `wav`, and `pcm`.
  37. #
  38. # @return [Symbol, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat, nil]
  39. 1 optional :response_format, enum: -> { OpenAI::Audio::SpeechCreateParams::ResponseFormat }
  40. # @!attribute speed
  41. # The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
  42. # the default.
  43. #
  44. # @return [Float, nil]
  45. 1 optional :speed, Float
  46. # @!attribute stream_format
  47. # The format to stream the audio in. Supported formats are `sse` and `audio`.
  48. # `sse` is not supported for `tts-1` or `tts-1-hd`.
  49. #
  50. # @return [Symbol, OpenAI::Models::Audio::SpeechCreateParams::StreamFormat, nil]
  51. 1 optional :stream_format, enum: -> { OpenAI::Audio::SpeechCreateParams::StreamFormat }
  52. # @!method initialize(input:, model:, voice:, instructions: nil, response_format: nil, speed: nil, stream_format: nil, request_options: {})
  53. # Some parameter documentations has been truncated, see
  54. # {OpenAI::Models::Audio::SpeechCreateParams} for more details.
  55. #
  56. # @param input [String] The text to generate audio for. The maximum length is 4096 characters.
  57. #
  58. # @param model [String, Symbol, OpenAI::Models::Audio::SpeechModel] One of the available [TTS models](https://platform.openai.com/docs/models#tts):
  59. #
  60. # @param voice [String, Symbol, OpenAI::Models::Audio::SpeechCreateParams::Voice] The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
  61. #
  62. # @param instructions [String] Control the voice of your generated audio with additional instructions. Does not
  63. #
  64. # @param response_format [Symbol, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat] The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav
  65. #
  66. # @param speed [Float] The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
  67. #
  68. # @param stream_format [Symbol, OpenAI::Models::Audio::SpeechCreateParams::StreamFormat] The format to stream the audio in. Supported formats are `sse` and `audio`. `sse
  69. #
  70. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  71. # One of the available [TTS models](https://platform.openai.com/docs/models#tts):
  72. # `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
  73. 1 module Model
  74. 1 extend OpenAI::Internal::Type::Union
  75. 1 variant String
  76. # One of the available [TTS models](https://platform.openai.com/docs/models#tts): `tts-1`, `tts-1-hd` or `gpt-4o-mini-tts`.
  77. 1 variant enum: -> { OpenAI::Audio::SpeechModel }
  78. # @!method self.variants
  79. # @return [Array(String, Symbol, OpenAI::Models::Audio::SpeechModel)]
  80. end
  81. # The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
  82. # `ballad`, `coral`, `echo`, `fable`, `onyx`, `nova`, `sage`, `shimmer`, and
  83. # `verse`. Previews of the voices are available in the
  84. # [Text to speech guide](https://platform.openai.com/docs/guides/text-to-speech#voice-options).
  85. 1 module Voice
  86. 1 extend OpenAI::Internal::Type::Union
  87. 1 variant String
  88. 1 variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::ALLOY }
  89. 1 variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::ASH }
  90. 1 variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::BALLAD }
  91. 1 variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::CORAL }
  92. 1 variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::ECHO }
  93. 1 variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::SAGE }
  94. 1 variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::SHIMMER }
  95. 1 variant const: -> { OpenAI::Models::Audio::SpeechCreateParams::Voice::VERSE }
  96. # @!method self.variants
  97. # @return [Array(String, Symbol)]
  98. 1 define_sorbet_constant!(:Variants) do
  99. T.type_alias { T.any(String, OpenAI::Audio::SpeechCreateParams::Voice::TaggedSymbol) }
  100. end
  101. # @!group
  102. 1 ALLOY = :alloy
  103. 1 ASH = :ash
  104. 1 BALLAD = :ballad
  105. 1 CORAL = :coral
  106. 1 ECHO = :echo
  107. 1 SAGE = :sage
  108. 1 SHIMMER = :shimmer
  109. 1 VERSE = :verse
  110. # @!endgroup
  111. end
  112. # The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`,
  113. # `wav`, and `pcm`.
  114. 1 module ResponseFormat
  115. 1 extend OpenAI::Internal::Type::Enum
  116. 1 MP3 = :mp3
  117. 1 OPUS = :opus
  118. 1 AAC = :aac
  119. 1 FLAC = :flac
  120. 1 WAV = :wav
  121. 1 PCM = :pcm
  122. # @!method self.values
  123. # @return [Array<Symbol>]
  124. end
  125. # The format to stream the audio in. Supported formats are `sse` and `audio`.
  126. # `sse` is not supported for `tts-1` or `tts-1-hd`.
  127. 1 module StreamFormat
  128. 1 extend OpenAI::Internal::Type::Enum
  129. 1 SSE = :sse
  130. 1 AUDIO = :audio
  131. # @!method self.values
  132. # @return [Array<Symbol>]
  133. end
  134. end
  135. end
  136. end
  137. end

openai-ruby/lib/openai/models/audio/speech_model.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 module SpeechModel
  6. 1 extend OpenAI::Internal::Type::Enum
  7. 1 TTS_1 = :"tts-1"
  8. 1 TTS_1_HD = :"tts-1-hd"
  9. 1 GPT_4O_MINI_TTS = :"gpt-4o-mini-tts"
  10. # @!method self.values
  11. # @return [Array<Symbol>]
  12. end
  13. end
  14. end
  15. end

openai-ruby/lib/openai/models/audio/transcription.rb

96.55% lines covered

100.0% branches covered

29 relevant lines. 28 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 class Transcription < OpenAI::Internal::Type::BaseModel
  6. # @!attribute text
  7. # The transcribed text.
  8. #
  9. # @return [String]
  10. 1 required :text, String
  11. # @!attribute logprobs
  12. # The log probabilities of the tokens in the transcription. Only returned with the
  13. # models `gpt-4o-transcribe` and `gpt-4o-mini-transcribe` if `logprobs` is added
  14. # to the `include` array.
  15. #
  16. # @return [Array<OpenAI::Models::Audio::Transcription::Logprob>, nil]
  17. 1 optional :logprobs, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::Transcription::Logprob] }
  18. # @!attribute usage
  19. # Token usage statistics for the request.
  20. #
  21. # @return [OpenAI::Models::Audio::Transcription::Usage::Tokens, OpenAI::Models::Audio::Transcription::Usage::Duration, nil]
  22. 1 optional :usage, union: -> { OpenAI::Audio::Transcription::Usage }
  23. # @!method initialize(text:, logprobs: nil, usage: nil)
  24. # Some parameter documentations has been truncated, see
  25. # {OpenAI::Models::Audio::Transcription} for more details.
  26. #
  27. # Represents a transcription response returned by model, based on the provided
  28. # input.
  29. #
  30. # @param text [String] The transcribed text.
  31. #
  32. # @param logprobs [Array<OpenAI::Models::Audio::Transcription::Logprob>] The log probabilities of the tokens in the transcription. Only returned with the
  33. #
  34. # @param usage [OpenAI::Models::Audio::Transcription::Usage::Tokens, OpenAI::Models::Audio::Transcription::Usage::Duration] Token usage statistics for the request.
  35. 1 class Logprob < OpenAI::Internal::Type::BaseModel
  36. # @!attribute token
  37. # The token in the transcription.
  38. #
  39. # @return [String, nil]
  40. 1 optional :token, String
  41. # @!attribute bytes
  42. # The bytes of the token.
  43. #
  44. # @return [Array<Float>, nil]
  45. 1 optional :bytes, OpenAI::Internal::Type::ArrayOf[Float]
  46. # @!attribute logprob
  47. # The log probability of the token.
  48. #
  49. # @return [Float, nil]
  50. 1 optional :logprob, Float
  51. # @!method initialize(token: nil, bytes: nil, logprob: nil)
  52. # @param token [String] The token in the transcription.
  53. #
  54. # @param bytes [Array<Float>] The bytes of the token.
  55. #
  56. # @param logprob [Float] The log probability of the token.
  57. end
  58. # Token usage statistics for the request.
  59. #
  60. # @see OpenAI::Models::Audio::Transcription#usage
  61. 1 module Usage
  62. 1 extend OpenAI::Internal::Type::Union
  63. 1 discriminator :type
  64. # Usage statistics for models billed by token usage.
  65. 1 variant :tokens, -> { OpenAI::Audio::Transcription::Usage::Tokens }
  66. # Usage statistics for models billed by audio input duration.
  67. 1 variant :duration, -> { OpenAI::Audio::Transcription::Usage::Duration }
  68. 1 class Tokens < OpenAI::Internal::Type::BaseModel
  69. # @!attribute input_tokens
  70. # Number of input tokens billed for this request.
  71. #
  72. # @return [Integer]
  73. 1 required :input_tokens, Integer
  74. # @!attribute output_tokens
  75. # Number of output tokens generated.
  76. #
  77. # @return [Integer]
  78. 1 required :output_tokens, Integer
  79. # @!attribute total_tokens
  80. # Total number of tokens used (input + output).
  81. #
  82. # @return [Integer]
  83. 1 required :total_tokens, Integer
  84. # @!attribute type
  85. # The type of the usage object. Always `tokens` for this variant.
  86. #
  87. # @return [Symbol, :tokens]
  88. 1 required :type, const: :tokens
  89. # @!attribute input_token_details
  90. # Details about the input tokens billed for this request.
  91. #
  92. # @return [OpenAI::Models::Audio::Transcription::Usage::Tokens::InputTokenDetails, nil]
  93. 1 optional :input_token_details,
  94. -> {
  95. OpenAI::Audio::Transcription::Usage::Tokens::InputTokenDetails
  96. }
  97. # @!method initialize(input_tokens:, output_tokens:, total_tokens:, input_token_details: nil, type: :tokens)
  98. # Usage statistics for models billed by token usage.
  99. #
  100. # @param input_tokens [Integer] Number of input tokens billed for this request.
  101. #
  102. # @param output_tokens [Integer] Number of output tokens generated.
  103. #
  104. # @param total_tokens [Integer] Total number of tokens used (input + output).
  105. #
  106. # @param input_token_details [OpenAI::Models::Audio::Transcription::Usage::Tokens::InputTokenDetails] Details about the input tokens billed for this request.
  107. #
  108. # @param type [Symbol, :tokens] The type of the usage object. Always `tokens` for this variant.
  109. # @see OpenAI::Models::Audio::Transcription::Usage::Tokens#input_token_details
  110. 1 class InputTokenDetails < OpenAI::Internal::Type::BaseModel
  111. # @!attribute audio_tokens
  112. # Number of audio tokens billed for this request.
  113. #
  114. # @return [Integer, nil]
  115. 1 optional :audio_tokens, Integer
  116. # @!attribute text_tokens
  117. # Number of text tokens billed for this request.
  118. #
  119. # @return [Integer, nil]
  120. 1 optional :text_tokens, Integer
  121. # @!method initialize(audio_tokens: nil, text_tokens: nil)
  122. # Details about the input tokens billed for this request.
  123. #
  124. # @param audio_tokens [Integer] Number of audio tokens billed for this request.
  125. #
  126. # @param text_tokens [Integer] Number of text tokens billed for this request.
  127. end
  128. end
  129. 1 class Duration < OpenAI::Internal::Type::BaseModel
  130. # @!attribute seconds
  131. # Duration of the input audio in seconds.
  132. #
  133. # @return [Float]
  134. 1 required :seconds, Float
  135. # @!attribute type
  136. # The type of the usage object. Always `duration` for this variant.
  137. #
  138. # @return [Symbol, :duration]
  139. 1 required :type, const: :duration
  140. # @!method initialize(seconds:, type: :duration)
  141. # Usage statistics for models billed by audio input duration.
  142. #
  143. # @param seconds [Float] Duration of the input audio in seconds.
  144. #
  145. # @param type [Symbol, :duration] The type of the usage object. Always `duration` for this variant.
  146. end
  147. # @!method self.variants
  148. # @return [Array(OpenAI::Models::Audio::Transcription::Usage::Tokens, OpenAI::Models::Audio::Transcription::Usage::Duration)]
  149. end
  150. end
  151. end
  152. end
  153. end

openai-ruby/lib/openai/models/audio/transcription_create_params.rb

92.11% lines covered

100.0% branches covered

38 relevant lines. 35 lines covered and 3 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. # @see OpenAI::Resources::Audio::Transcriptions#create
  6. #
  7. # @see OpenAI::Resources::Audio::Transcriptions#create_streaming
  8. 1 class TranscriptionCreateParams < OpenAI::Internal::Type::BaseModel
  9. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  10. 1 include OpenAI::Internal::Type::RequestParameters
  11. # @!attribute file
  12. # The audio file object (not file name) to transcribe, in one of these formats:
  13. # flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
  14. #
  15. # @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
  16. 1 required :file, OpenAI::Internal::Type::FileInput
  17. # @!attribute model
  18. # ID of the model to use. The options are `gpt-4o-transcribe`,
  19. # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
  20. # Whisper V2 model).
  21. #
  22. # @return [String, Symbol, OpenAI::Models::AudioModel]
  23. 1 required :model, union: -> { OpenAI::Audio::TranscriptionCreateParams::Model }
  24. # @!attribute chunking_strategy
  25. # Controls how the audio is cut into chunks. When set to `"auto"`, the server
  26. # first normalizes loudness and then uses voice activity detection (VAD) to choose
  27. # boundaries. `server_vad` object can be provided to tweak VAD detection
  28. # parameters manually. If unset, the audio is transcribed as a single block.
  29. #
  30. # @return [Symbol, :auto, OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig, nil]
  31. 1 optional :chunking_strategy,
  32. union: -> { OpenAI::Audio::TranscriptionCreateParams::ChunkingStrategy },
  33. nil?: true
  34. # @!attribute include
  35. # Additional information to include in the transcription response. `logprobs` will
  36. # return the log probabilities of the tokens in the response to understand the
  37. # model's confidence in the transcription. `logprobs` only works with
  38. # response_format set to `json` and only with the models `gpt-4o-transcribe` and
  39. # `gpt-4o-mini-transcribe`.
  40. #
  41. # @return [Array<Symbol, OpenAI::Models::Audio::TranscriptionInclude>, nil]
  42. 1 optional :include, -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Audio::TranscriptionInclude] }
  43. # @!attribute language
  44. # The language of the input audio. Supplying the input language in
  45. # [ISO-639-1](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g. `en`)
  46. # format will improve accuracy and latency.
  47. #
  48. # @return [String, nil]
  49. 1 optional :language, String
  50. # @!attribute prompt
  51. # An optional text to guide the model's style or continue a previous audio
  52. # segment. The
  53. # [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
  54. # should match the audio language.
  55. #
  56. # @return [String, nil]
  57. 1 optional :prompt, String
  58. # @!attribute response_format
  59. # The format of the output, in one of these options: `json`, `text`, `srt`,
  60. # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
  61. # the only supported format is `json`.
  62. #
  63. # @return [Symbol, OpenAI::Models::AudioResponseFormat, nil]
  64. 1 optional :response_format, enum: -> { OpenAI::AudioResponseFormat }
  65. # @!attribute temperature
  66. # The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
  67. # output more random, while lower values like 0.2 will make it more focused and
  68. # deterministic. If set to 0, the model will use
  69. # [log probability](https://en.wikipedia.org/wiki/Log_probability) to
  70. # automatically increase the temperature until certain thresholds are hit.
  71. #
  72. # @return [Float, nil]
  73. 1 optional :temperature, Float
  74. # @!attribute timestamp_granularities
  75. # The timestamp granularities to populate for this transcription.
  76. # `response_format` must be set `verbose_json` to use timestamp granularities.
  77. # Either or both of these options are supported: `word`, or `segment`. Note: There
  78. # is no additional latency for segment timestamps, but generating word timestamps
  79. # incurs additional latency.
  80. #
  81. # @return [Array<Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity>, nil]
  82. 1 optional :timestamp_granularities,
  83. -> {
  84. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Audio::TranscriptionCreateParams::TimestampGranularity]
  85. }
  86. # @!method initialize(file:, model:, chunking_strategy: nil, include: nil, language: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {})
  87. # Some parameter documentations has been truncated, see
  88. # {OpenAI::Models::Audio::TranscriptionCreateParams} for more details.
  89. #
  90. # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) to transcribe, in one of these formats: fl
  91. #
  92. # @param model [String, Symbol, OpenAI::Models::AudioModel] ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transc
  93. #
  94. # @param chunking_strategy [Symbol, :auto, OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig, nil] Controls how the audio is cut into chunks. When set to `"auto"`, the server firs
  95. #
  96. # @param include [Array<Symbol, OpenAI::Models::Audio::TranscriptionInclude>] Additional information to include in the transcription response.
  97. #
  98. # @param language [String] The language of the input audio. Supplying the input language in [ISO-639-1](htt
  99. #
  100. # @param prompt [String] An optional text to guide the model's style or continue a previous audio segment
  101. #
  102. # @param response_format [Symbol, OpenAI::Models::AudioResponseFormat] The format of the output, in one of these options: `json`, `text`, `srt`, `verbo
  103. #
  104. # @param temperature [Float] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
  105. #
  106. # @param timestamp_granularities [Array<Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity>] The timestamp granularities to populate for this transcription. `response_format
  107. #
  108. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  109. # ID of the model to use. The options are `gpt-4o-transcribe`,
  110. # `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source
  111. # Whisper V2 model).
  112. 1 module Model
  113. 1 extend OpenAI::Internal::Type::Union
  114. 1 variant String
  115. # ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transcribe`, and `whisper-1` (which is powered by our open source Whisper V2 model).
  116. 1 variant enum: -> { OpenAI::AudioModel }
  117. # @!method self.variants
  118. # @return [Array(String, Symbol, OpenAI::Models::AudioModel)]
  119. end
  120. # Controls how the audio is cut into chunks. When set to `"auto"`, the server
  121. # first normalizes loudness and then uses voice activity detection (VAD) to choose
  122. # boundaries. `server_vad` object can be provided to tweak VAD detection
  123. # parameters manually. If unset, the audio is transcribed as a single block.
  124. 1 module ChunkingStrategy
  125. 1 extend OpenAI::Internal::Type::Union
  126. # Automatically set chunking parameters based on the audio. Must be set to `"auto"`.
  127. 1 variant const: :auto
  128. 1 variant -> { OpenAI::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig }
  129. 1 class VadConfig < OpenAI::Internal::Type::BaseModel
  130. # @!attribute type
  131. # Must be set to `server_vad` to enable manual chunking using server side VAD.
  132. #
  133. # @return [Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig::Type]
  134. 1 required :type,
  135. enum: -> {
  136. OpenAI::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig::Type
  137. }
  138. # @!attribute prefix_padding_ms
  139. # Amount of audio to include before the VAD detected speech (in milliseconds).
  140. #
  141. # @return [Integer, nil]
  142. 1 optional :prefix_padding_ms, Integer
  143. # @!attribute silence_duration_ms
  144. # Duration of silence to detect speech stop (in milliseconds). With shorter values
  145. # the model will respond more quickly, but may jump in on short pauses from the
  146. # user.
  147. #
  148. # @return [Integer, nil]
  149. 1 optional :silence_duration_ms, Integer
  150. # @!attribute threshold
  151. # Sensitivity threshold (0.0 to 1.0) for voice activity detection. A higher
  152. # threshold will require louder audio to activate the model, and thus might
  153. # perform better in noisy environments.
  154. #
  155. # @return [Float, nil]
  156. 1 optional :threshold, Float
  157. # @!method initialize(type:, prefix_padding_ms: nil, silence_duration_ms: nil, threshold: nil)
  158. # Some parameter documentations has been truncated, see
  159. # {OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig}
  160. # for more details.
  161. #
  162. # @param type [Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig::Type] Must be set to `server_vad` to enable manual chunking using server side VAD.
  163. #
  164. # @param prefix_padding_ms [Integer] Amount of audio to include before the VAD detected speech (in
  165. #
  166. # @param silence_duration_ms [Integer] Duration of silence to detect speech stop (in milliseconds).
  167. #
  168. # @param threshold [Float] Sensitivity threshold (0.0 to 1.0) for voice activity detection. A
  169. # Must be set to `server_vad` to enable manual chunking using server side VAD.
  170. #
  171. # @see OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig#type
  172. 1 module Type
  173. 1 extend OpenAI::Internal::Type::Enum
  174. 1 SERVER_VAD = :server_vad
  175. # @!method self.values
  176. # @return [Array<Symbol>]
  177. end
  178. end
  179. # @!method self.variants
  180. # @return [Array(Symbol, :auto, OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig)]
  181. end
  182. 1 module TimestampGranularity
  183. 1 extend OpenAI::Internal::Type::Enum
  184. 1 WORD = :word
  185. 1 SEGMENT = :segment
  186. # @!method self.values
  187. # @return [Array<Symbol>]
  188. end
  189. end
  190. end
  191. end
  192. end

openai-ruby/lib/openai/models/audio/transcription_create_response.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. # Represents a transcription response returned by model, based on the provided
  6. # input.
  7. #
  8. # @see OpenAI::Resources::Audio::Transcriptions#create
  9. #
  10. # @see OpenAI::Resources::Audio::Transcriptions#create_streaming
  11. 1 module TranscriptionCreateResponse
  12. 1 extend OpenAI::Internal::Type::Union
  13. # Represents a transcription response returned by model, based on the provided input.
  14. 1 variant -> { OpenAI::Audio::Transcription }
  15. # Represents a verbose json transcription response returned by model, based on the provided input.
  16. 1 variant -> { OpenAI::Audio::TranscriptionVerbose }
  17. # @!method self.variants
  18. # @return [Array(OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose)]
  19. end
  20. end
  21. end
  22. end

openai-ruby/lib/openai/models/audio/transcription_include.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 module TranscriptionInclude
  6. 1 extend OpenAI::Internal::Type::Enum
  7. 1 LOGPROBS = :logprobs
  8. # @!method self.values
  9. # @return [Array<Symbol>]
  10. end
  11. end
  12. end
  13. end

openai-ruby/lib/openai/models/audio/transcription_segment.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 class TranscriptionSegment < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # Unique identifier of the segment.
  8. #
  9. # @return [Integer]
  10. 1 required :id, Integer
  11. # @!attribute avg_logprob
  12. # Average logprob of the segment. If the value is lower than -1, consider the
  13. # logprobs failed.
  14. #
  15. # @return [Float]
  16. 1 required :avg_logprob, Float
  17. # @!attribute compression_ratio
  18. # Compression ratio of the segment. If the value is greater than 2.4, consider the
  19. # compression failed.
  20. #
  21. # @return [Float]
  22. 1 required :compression_ratio, Float
  23. # @!attribute end_
  24. # End time of the segment in seconds.
  25. #
  26. # @return [Float]
  27. 1 required :end_, Float, api_name: :end
  28. # @!attribute no_speech_prob
  29. # Probability of no speech in the segment. If the value is higher than 1.0 and the
  30. # `avg_logprob` is below -1, consider this segment silent.
  31. #
  32. # @return [Float]
  33. 1 required :no_speech_prob, Float
  34. # @!attribute seek
  35. # Seek offset of the segment.
  36. #
  37. # @return [Integer]
  38. 1 required :seek, Integer
  39. # @!attribute start
  40. # Start time of the segment in seconds.
  41. #
  42. # @return [Float]
  43. 1 required :start, Float
  44. # @!attribute temperature
  45. # Temperature parameter used for generating the segment.
  46. #
  47. # @return [Float]
  48. 1 required :temperature, Float
  49. # @!attribute text
  50. # Text content of the segment.
  51. #
  52. # @return [String]
  53. 1 required :text, String
  54. # @!attribute tokens
  55. # Array of token IDs for the text content.
  56. #
  57. # @return [Array<Integer>]
  58. 1 required :tokens, OpenAI::Internal::Type::ArrayOf[Integer]
  59. # @!method initialize(id:, avg_logprob:, compression_ratio:, end_:, no_speech_prob:, seek:, start:, temperature:, text:, tokens:)
  60. # Some parameter documentations has been truncated, see
  61. # {OpenAI::Models::Audio::TranscriptionSegment} for more details.
  62. #
  63. # @param id [Integer] Unique identifier of the segment.
  64. #
  65. # @param avg_logprob [Float] Average logprob of the segment. If the value is lower than -1, consider the logp
  66. #
  67. # @param compression_ratio [Float] Compression ratio of the segment. If the value is greater than 2.4, consider the
  68. #
  69. # @param end_ [Float] End time of the segment in seconds.
  70. #
  71. # @param no_speech_prob [Float] Probability of no speech in the segment. If the value is higher than 1.0 and the
  72. #
  73. # @param seek [Integer] Seek offset of the segment.
  74. #
  75. # @param start [Float] Start time of the segment in seconds.
  76. #
  77. # @param temperature [Float] Temperature parameter used for generating the segment.
  78. #
  79. # @param text [String] Text content of the segment.
  80. #
  81. # @param tokens [Array<Integer>] Array of token IDs for the text content.
  82. end
  83. end
  84. end
  85. end

openai-ruby/lib/openai/models/audio/transcription_stream_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. # Emitted when there is an additional text delta. This is also the first event
  6. # emitted when the transcription starts. Only emitted when you
  7. # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
  8. # with the `Stream` parameter set to `true`.
  9. 1 module TranscriptionStreamEvent
  10. 1 extend OpenAI::Internal::Type::Union
  11. 1 discriminator :type
  12. # Emitted when there is an additional text delta. This is also the first event emitted when the transcription starts. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.
  13. 1 variant :"transcript.text.delta", -> { OpenAI::Audio::TranscriptionTextDeltaEvent }
  14. # Emitted when the transcription is complete. Contains the complete transcription text. Only emitted when you [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription) with the `Stream` parameter set to `true`.
  15. 1 variant :"transcript.text.done", -> { OpenAI::Audio::TranscriptionTextDoneEvent }
  16. # @!method self.variants
  17. # @return [Array(OpenAI::Models::Audio::TranscriptionTextDeltaEvent, OpenAI::Models::Audio::TranscriptionTextDoneEvent)]
  18. end
  19. end
  20. end
  21. end

openai-ruby/lib/openai/models/audio/transcription_text_delta_event.rb

91.67% lines covered

100.0% branches covered

12 relevant lines. 11 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 class TranscriptionTextDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute delta
  7. # The text delta that was additionally transcribed.
  8. #
  9. # @return [String]
  10. 1 required :delta, String
  11. # @!attribute type
  12. # The type of the event. Always `transcript.text.delta`.
  13. #
  14. # @return [Symbol, :"transcript.text.delta"]
  15. 1 required :type, const: :"transcript.text.delta"
  16. # @!attribute logprobs
  17. # The log probabilities of the delta. Only included if you
  18. # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
  19. # with the `include[]` parameter set to `logprobs`.
  20. #
  21. # @return [Array<OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob>, nil]
  22. 1 optional :logprobs,
  23. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::TranscriptionTextDeltaEvent::Logprob] }
  24. # @!method initialize(delta:, logprobs: nil, type: :"transcript.text.delta")
  25. # Some parameter documentations has been truncated, see
  26. # {OpenAI::Models::Audio::TranscriptionTextDeltaEvent} for more details.
  27. #
  28. # Emitted when there is an additional text delta. This is also the first event
  29. # emitted when the transcription starts. Only emitted when you
  30. # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
  31. # with the `Stream` parameter set to `true`.
  32. #
  33. # @param delta [String] The text delta that was additionally transcribed.
  34. #
  35. # @param logprobs [Array<OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob>] The log probabilities of the delta. Only included if you [create a transcription
  36. #
  37. # @param type [Symbol, :"transcript.text.delta"] The type of the event. Always `transcript.text.delta`.
  38. 1 class Logprob < OpenAI::Internal::Type::BaseModel
  39. # @!attribute token
  40. # The token that was used to generate the log probability.
  41. #
  42. # @return [String, nil]
  43. 1 optional :token, String
  44. # @!attribute bytes
  45. # The bytes that were used to generate the log probability.
  46. #
  47. # @return [Array<Integer>, nil]
  48. 1 optional :bytes, OpenAI::Internal::Type::ArrayOf[Integer]
  49. # @!attribute logprob
  50. # The log probability of the token.
  51. #
  52. # @return [Float, nil]
  53. 1 optional :logprob, Float
  54. # @!method initialize(token: nil, bytes: nil, logprob: nil)
  55. # Some parameter documentations has been truncated, see
  56. # {OpenAI::Models::Audio::TranscriptionTextDeltaEvent::Logprob} for more details.
  57. #
  58. # @param token [String] The token that was used to generate the log probability.
  59. #
  60. # @param bytes [Array<Integer>] The bytes that were used to generate the log probability.
  61. #
  62. # @param logprob [Float] The log probability of the token.
  63. end
  64. end
  65. end
  66. end
  67. end

openai-ruby/lib/openai/models/audio/transcription_text_done_event.rb

91.3% lines covered

100.0% branches covered

23 relevant lines. 21 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 class TranscriptionTextDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute text
  7. # The text that was transcribed.
  8. #
  9. # @return [String]
  10. 1 required :text, String
  11. # @!attribute type
  12. # The type of the event. Always `transcript.text.done`.
  13. #
  14. # @return [Symbol, :"transcript.text.done"]
  15. 1 required :type, const: :"transcript.text.done"
  16. # @!attribute logprobs
  17. # The log probabilities of the individual tokens in the transcription. Only
  18. # included if you
  19. # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
  20. # with the `include[]` parameter set to `logprobs`.
  21. #
  22. # @return [Array<OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob>, nil]
  23. 1 optional :logprobs,
  24. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::TranscriptionTextDoneEvent::Logprob] }
  25. # @!attribute usage
  26. # Usage statistics for models billed by token usage.
  27. #
  28. # @return [OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage, nil]
  29. 1 optional :usage, -> { OpenAI::Audio::TranscriptionTextDoneEvent::Usage }
  30. # @!method initialize(text:, logprobs: nil, usage: nil, type: :"transcript.text.done")
  31. # Some parameter documentations has been truncated, see
  32. # {OpenAI::Models::Audio::TranscriptionTextDoneEvent} for more details.
  33. #
  34. # Emitted when the transcription is complete. Contains the complete transcription
  35. # text. Only emitted when you
  36. # [create a transcription](https://platform.openai.com/docs/api-reference/audio/create-transcription)
  37. # with the `Stream` parameter set to `true`.
  38. #
  39. # @param text [String] The text that was transcribed.
  40. #
  41. # @param logprobs [Array<OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob>] The log probabilities of the individual tokens in the transcription. Only includ
  42. #
  43. # @param usage [OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage] Usage statistics for models billed by token usage.
  44. #
  45. # @param type [Symbol, :"transcript.text.done"] The type of the event. Always `transcript.text.done`.
  46. 1 class Logprob < OpenAI::Internal::Type::BaseModel
  47. # @!attribute token
  48. # The token that was used to generate the log probability.
  49. #
  50. # @return [String, nil]
  51. 1 optional :token, String
  52. # @!attribute bytes
  53. # The bytes that were used to generate the log probability.
  54. #
  55. # @return [Array<Integer>, nil]
  56. 1 optional :bytes, OpenAI::Internal::Type::ArrayOf[Integer]
  57. # @!attribute logprob
  58. # The log probability of the token.
  59. #
  60. # @return [Float, nil]
  61. 1 optional :logprob, Float
  62. # @!method initialize(token: nil, bytes: nil, logprob: nil)
  63. # Some parameter documentations has been truncated, see
  64. # {OpenAI::Models::Audio::TranscriptionTextDoneEvent::Logprob} for more details.
  65. #
  66. # @param token [String] The token that was used to generate the log probability.
  67. #
  68. # @param bytes [Array<Integer>] The bytes that were used to generate the log probability.
  69. #
  70. # @param logprob [Float] The log probability of the token.
  71. end
  72. # @see OpenAI::Models::Audio::TranscriptionTextDoneEvent#usage
  73. 1 class Usage < OpenAI::Internal::Type::BaseModel
  74. # @!attribute input_tokens
  75. # Number of input tokens billed for this request.
  76. #
  77. # @return [Integer]
  78. 1 required :input_tokens, Integer
  79. # @!attribute output_tokens
  80. # Number of output tokens generated.
  81. #
  82. # @return [Integer]
  83. 1 required :output_tokens, Integer
  84. # @!attribute total_tokens
  85. # Total number of tokens used (input + output).
  86. #
  87. # @return [Integer]
  88. 1 required :total_tokens, Integer
  89. # @!attribute type
  90. # The type of the usage object. Always `tokens` for this variant.
  91. #
  92. # @return [Symbol, :tokens]
  93. 1 required :type, const: :tokens
  94. # @!attribute input_token_details
  95. # Details about the input tokens billed for this request.
  96. #
  97. # @return [OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails, nil]
  98. 1 optional :input_token_details,
  99. -> {
  100. OpenAI::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails
  101. }
  102. # @!method initialize(input_tokens:, output_tokens:, total_tokens:, input_token_details: nil, type: :tokens)
  103. # Usage statistics for models billed by token usage.
  104. #
  105. # @param input_tokens [Integer] Number of input tokens billed for this request.
  106. #
  107. # @param output_tokens [Integer] Number of output tokens generated.
  108. #
  109. # @param total_tokens [Integer] Total number of tokens used (input + output).
  110. #
  111. # @param input_token_details [OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage::InputTokenDetails] Details about the input tokens billed for this request.
  112. #
  113. # @param type [Symbol, :tokens] The type of the usage object. Always `tokens` for this variant.
  114. # @see OpenAI::Models::Audio::TranscriptionTextDoneEvent::Usage#input_token_details
  115. 1 class InputTokenDetails < OpenAI::Internal::Type::BaseModel
  116. # @!attribute audio_tokens
  117. # Number of audio tokens billed for this request.
  118. #
  119. # @return [Integer, nil]
  120. 1 optional :audio_tokens, Integer
  121. # @!attribute text_tokens
  122. # Number of text tokens billed for this request.
  123. #
  124. # @return [Integer, nil]
  125. 1 optional :text_tokens, Integer
  126. # @!method initialize(audio_tokens: nil, text_tokens: nil)
  127. # Details about the input tokens billed for this request.
  128. #
  129. # @param audio_tokens [Integer] Number of audio tokens billed for this request.
  130. #
  131. # @param text_tokens [Integer] Number of text tokens billed for this request.
  132. end
  133. end
  134. end
  135. end
  136. end
  137. end

openai-ruby/lib/openai/models/audio/transcription_verbose.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 class TranscriptionVerbose < OpenAI::Internal::Type::BaseModel
  6. # @!attribute duration
  7. # The duration of the input audio.
  8. #
  9. # @return [Float]
  10. 1 required :duration, Float
  11. # @!attribute language
  12. # The language of the input audio.
  13. #
  14. # @return [String]
  15. 1 required :language, String
  16. # @!attribute text
  17. # The transcribed text.
  18. #
  19. # @return [String]
  20. 1 required :text, String
  21. # @!attribute segments
  22. # Segments of the transcribed text and their corresponding details.
  23. #
  24. # @return [Array<OpenAI::Models::Audio::TranscriptionSegment>, nil]
  25. 1 optional :segments, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::TranscriptionSegment] }
  26. # @!attribute usage
  27. # Usage statistics for models billed by audio input duration.
  28. #
  29. # @return [OpenAI::Models::Audio::TranscriptionVerbose::Usage, nil]
  30. 1 optional :usage, -> { OpenAI::Audio::TranscriptionVerbose::Usage }
  31. # @!attribute words
  32. # Extracted words and their corresponding timestamps.
  33. #
  34. # @return [Array<OpenAI::Models::Audio::TranscriptionWord>, nil]
  35. 1 optional :words, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::TranscriptionWord] }
  36. # @!method initialize(duration:, language:, text:, segments: nil, usage: nil, words: nil)
  37. # Represents a verbose json transcription response returned by model, based on the
  38. # provided input.
  39. #
  40. # @param duration [Float] The duration of the input audio.
  41. #
  42. # @param language [String] The language of the input audio.
  43. #
  44. # @param text [String] The transcribed text.
  45. #
  46. # @param segments [Array<OpenAI::Models::Audio::TranscriptionSegment>] Segments of the transcribed text and their corresponding details.
  47. #
  48. # @param usage [OpenAI::Models::Audio::TranscriptionVerbose::Usage] Usage statistics for models billed by audio input duration.
  49. #
  50. # @param words [Array<OpenAI::Models::Audio::TranscriptionWord>] Extracted words and their corresponding timestamps.
  51. # @see OpenAI::Models::Audio::TranscriptionVerbose#usage
  52. 1 class Usage < OpenAI::Internal::Type::BaseModel
  53. # @!attribute seconds
  54. # Duration of the input audio in seconds.
  55. #
  56. # @return [Float]
  57. 1 required :seconds, Float
  58. # @!attribute type
  59. # The type of the usage object. Always `duration` for this variant.
  60. #
  61. # @return [Symbol, :duration]
  62. 1 required :type, const: :duration
  63. # @!method initialize(seconds:, type: :duration)
  64. # Usage statistics for models billed by audio input duration.
  65. #
  66. # @param seconds [Float] Duration of the input audio in seconds.
  67. #
  68. # @param type [Symbol, :duration] The type of the usage object. Always `duration` for this variant.
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/audio/transcription_word.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 class TranscriptionWord < OpenAI::Internal::Type::BaseModel
  6. # @!attribute end_
  7. # End time of the word in seconds.
  8. #
  9. # @return [Float]
  10. 1 required :end_, Float, api_name: :end
  11. # @!attribute start
  12. # Start time of the word in seconds.
  13. #
  14. # @return [Float]
  15. 1 required :start, Float
  16. # @!attribute word
  17. # The text content of the word.
  18. #
  19. # @return [String]
  20. 1 required :word, String
  21. # @!method initialize(end_:, start:, word:)
  22. # @param end_ [Float] End time of the word in seconds.
  23. #
  24. # @param start [Float] Start time of the word in seconds.
  25. #
  26. # @param word [String] The text content of the word.
  27. end
  28. end
  29. end
  30. end

openai-ruby/lib/openai/models/audio/translation.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 class Translation < OpenAI::Internal::Type::BaseModel
  6. # @!attribute text
  7. #
  8. # @return [String]
  9. 1 required :text, String
  10. # @!method initialize(text:)
  11. # @param text [String]
  12. end
  13. end
  14. end
  15. end

openai-ruby/lib/openai/models/audio/translation_create_params.rb

100.0% lines covered

100.0% branches covered

22 relevant lines. 22 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. # @see OpenAI::Resources::Audio::Translations#create
  6. 1 class TranslationCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute file
  10. # The audio file object (not file name) translate, in one of these formats: flac,
  11. # mp3, mp4, mpeg, mpga, m4a, ogg, wav, or webm.
  12. #
  13. # @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
  14. 1 required :file, OpenAI::Internal::Type::FileInput
  15. # @!attribute model
  16. # ID of the model to use. Only `whisper-1` (which is powered by our open source
  17. # Whisper V2 model) is currently available.
  18. #
  19. # @return [String, Symbol, OpenAI::Models::AudioModel]
  20. 1 required :model, union: -> { OpenAI::Audio::TranslationCreateParams::Model }
  21. # @!attribute prompt
  22. # An optional text to guide the model's style or continue a previous audio
  23. # segment. The
  24. # [prompt](https://platform.openai.com/docs/guides/speech-to-text#prompting)
  25. # should be in English.
  26. #
  27. # @return [String, nil]
  28. 1 optional :prompt, String
  29. # @!attribute response_format
  30. # The format of the output, in one of these options: `json`, `text`, `srt`,
  31. # `verbose_json`, or `vtt`.
  32. #
  33. # @return [Symbol, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat, nil]
  34. 1 optional :response_format, enum: -> { OpenAI::Audio::TranslationCreateParams::ResponseFormat }
  35. # @!attribute temperature
  36. # The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
  37. # output more random, while lower values like 0.2 will make it more focused and
  38. # deterministic. If set to 0, the model will use
  39. # [log probability](https://en.wikipedia.org/wiki/Log_probability) to
  40. # automatically increase the temperature until certain thresholds are hit.
  41. #
  42. # @return [Float, nil]
  43. 1 optional :temperature, Float
  44. # @!method initialize(file:, model:, prompt: nil, response_format: nil, temperature: nil, request_options: {})
  45. # Some parameter documentations has been truncated, see
  46. # {OpenAI::Models::Audio::TranslationCreateParams} for more details.
  47. #
  48. # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) translate, in one of these formats: flac,
  49. #
  50. # @param model [String, Symbol, OpenAI::Models::AudioModel] ID of the model to use. Only `whisper-1` (which is powered by our open source Wh
  51. #
  52. # @param prompt [String] An optional text to guide the model's style or continue a previous audio segment
  53. #
  54. # @param response_format [Symbol, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat] The format of the output, in one of these options: `json`, `text`, `srt`, `verbo
  55. #
  56. # @param temperature [Float] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
  57. #
  58. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  59. # ID of the model to use. Only `whisper-1` (which is powered by our open source
  60. # Whisper V2 model) is currently available.
  61. 1 module Model
  62. 1 extend OpenAI::Internal::Type::Union
  63. 1 variant String
  64. # ID of the model to use. Only `whisper-1` (which is powered by our open source Whisper V2 model) is currently available.
  65. 1 variant enum: -> { OpenAI::AudioModel }
  66. # @!method self.variants
  67. # @return [Array(String, Symbol, OpenAI::Models::AudioModel)]
  68. end
  69. # The format of the output, in one of these options: `json`, `text`, `srt`,
  70. # `verbose_json`, or `vtt`.
  71. 1 module ResponseFormat
  72. 1 extend OpenAI::Internal::Type::Enum
  73. 1 JSON = :json
  74. 1 TEXT = :text
  75. 1 SRT = :srt
  76. 1 VERBOSE_JSON = :verbose_json
  77. 1 VTT = :vtt
  78. # @!method self.values
  79. # @return [Array<Symbol>]
  80. end
  81. end
  82. end
  83. end
  84. end

openai-ruby/lib/openai/models/audio/translation_create_response.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. # @see OpenAI::Resources::Audio::Translations#create
  6. 1 module TranslationCreateResponse
  7. 1 extend OpenAI::Internal::Type::Union
  8. 1 variant -> { OpenAI::Audio::Translation }
  9. 1 variant -> { OpenAI::Audio::TranslationVerbose }
  10. # @!method self.variants
  11. # @return [Array(OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose)]
  12. end
  13. end
  14. end
  15. end

openai-ruby/lib/openai/models/audio/translation_verbose.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Audio
  5. 1 class TranslationVerbose < OpenAI::Internal::Type::BaseModel
  6. # @!attribute duration
  7. # The duration of the input audio.
  8. #
  9. # @return [Float]
  10. 1 required :duration, Float
  11. # @!attribute language
  12. # The language of the output translation (always `english`).
  13. #
  14. # @return [String]
  15. 1 required :language, String
  16. # @!attribute text
  17. # The translated text.
  18. #
  19. # @return [String]
  20. 1 required :text, String
  21. # @!attribute segments
  22. # Segments of the translated text and their corresponding details.
  23. #
  24. # @return [Array<OpenAI::Models::Audio::TranscriptionSegment>, nil]
  25. 1 optional :segments, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Audio::TranscriptionSegment] }
  26. # @!method initialize(duration:, language:, text:, segments: nil)
  27. # @param duration [Float] The duration of the input audio.
  28. #
  29. # @param language [String] The language of the output translation (always `english`).
  30. #
  31. # @param text [String] The translated text.
  32. #
  33. # @param segments [Array<OpenAI::Models::Audio::TranscriptionSegment>] Segments of the translated text and their corresponding details.
  34. end
  35. end
  36. end
  37. end

openai-ruby/lib/openai/models/audio_model.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module AudioModel
  5. 1 extend OpenAI::Internal::Type::Enum
  6. 1 WHISPER_1 = :"whisper-1"
  7. 1 GPT_4O_TRANSCRIBE = :"gpt-4o-transcribe"
  8. 1 GPT_4O_MINI_TRANSCRIBE = :"gpt-4o-mini-transcribe"
  9. # @!method self.values
  10. # @return [Array<Symbol>]
  11. end
  12. end
  13. end

openai-ruby/lib/openai/models/audio_response_format.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # The format of the output, in one of these options: `json`, `text`, `srt`,
  5. # `verbose_json`, or `vtt`. For `gpt-4o-transcribe` and `gpt-4o-mini-transcribe`,
  6. # the only supported format is `json`.
  7. 1 module AudioResponseFormat
  8. 1 extend OpenAI::Internal::Type::Enum
  9. 1 JSON = :json
  10. 1 TEXT = :text
  11. 1 SRT = :srt
  12. 1 VERBOSE_JSON = :verbose_json
  13. 1 VTT = :vtt
  14. # @!method self.values
  15. # @return [Array<Symbol>]
  16. end
  17. end
  18. end

openai-ruby/lib/openai/models/auto_file_chunking_strategy_param.rb

100.0% lines covered

100.0% branches covered

4 relevant lines. 4 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class AutoFileChunkingStrategyParam < OpenAI::Internal::Type::BaseModel
  5. # @!attribute type
  6. # Always `auto`.
  7. #
  8. # @return [Symbol, :auto]
  9. 1 required :type, const: :auto
  10. # @!method initialize(type: :auto)
  11. # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
  12. # `800` and `chunk_overlap_tokens` of `400`.
  13. #
  14. # @param type [Symbol, :auto] Always `auto`.
  15. end
  16. end
  17. end

openai-ruby/lib/openai/models/batch.rb

100.0% lines covered

100.0% branches covered

36 relevant lines. 36 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Batches#create
  5. 1 class Batch < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. #
  8. # @return [String]
  9. 1 required :id, String
  10. # @!attribute completion_window
  11. # The time frame within which the batch should be processed.
  12. #
  13. # @return [String]
  14. 1 required :completion_window, String
  15. # @!attribute created_at
  16. # The Unix timestamp (in seconds) for when the batch was created.
  17. #
  18. # @return [Integer]
  19. 1 required :created_at, Integer
  20. # @!attribute endpoint
  21. # The OpenAI API endpoint used by the batch.
  22. #
  23. # @return [String]
  24. 1 required :endpoint, String
  25. # @!attribute input_file_id
  26. # The ID of the input file for the batch.
  27. #
  28. # @return [String]
  29. 1 required :input_file_id, String
  30. # @!attribute object
  31. # The object type, which is always `batch`.
  32. #
  33. # @return [Symbol, :batch]
  34. 1 required :object, const: :batch
  35. # @!attribute status
  36. # The current status of the batch.
  37. #
  38. # @return [Symbol, OpenAI::Models::Batch::Status]
  39. 1 required :status, enum: -> { OpenAI::Batch::Status }
  40. # @!attribute cancelled_at
  41. # The Unix timestamp (in seconds) for when the batch was cancelled.
  42. #
  43. # @return [Integer, nil]
  44. 1 optional :cancelled_at, Integer
  45. # @!attribute cancelling_at
  46. # The Unix timestamp (in seconds) for when the batch started cancelling.
  47. #
  48. # @return [Integer, nil]
  49. 1 optional :cancelling_at, Integer
  50. # @!attribute completed_at
  51. # The Unix timestamp (in seconds) for when the batch was completed.
  52. #
  53. # @return [Integer, nil]
  54. 1 optional :completed_at, Integer
  55. # @!attribute error_file_id
  56. # The ID of the file containing the outputs of requests with errors.
  57. #
  58. # @return [String, nil]
  59. 1 optional :error_file_id, String
  60. # @!attribute errors
  61. #
  62. # @return [OpenAI::Models::Batch::Errors, nil]
  63. 1 optional :errors, -> { OpenAI::Batch::Errors }
  64. # @!attribute expired_at
  65. # The Unix timestamp (in seconds) for when the batch expired.
  66. #
  67. # @return [Integer, nil]
  68. 1 optional :expired_at, Integer
  69. # @!attribute expires_at
  70. # The Unix timestamp (in seconds) for when the batch will expire.
  71. #
  72. # @return [Integer, nil]
  73. 1 optional :expires_at, Integer
  74. # @!attribute failed_at
  75. # The Unix timestamp (in seconds) for when the batch failed.
  76. #
  77. # @return [Integer, nil]
  78. 1 optional :failed_at, Integer
  79. # @!attribute finalizing_at
  80. # The Unix timestamp (in seconds) for when the batch started finalizing.
  81. #
  82. # @return [Integer, nil]
  83. 1 optional :finalizing_at, Integer
  84. # @!attribute in_progress_at
  85. # The Unix timestamp (in seconds) for when the batch started processing.
  86. #
  87. # @return [Integer, nil]
  88. 1 optional :in_progress_at, Integer
  89. # @!attribute metadata
  90. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  91. # for storing additional information about the object in a structured format, and
  92. # querying for objects via API or the dashboard.
  93. #
  94. # Keys are strings with a maximum length of 64 characters. Values are strings with
  95. # a maximum length of 512 characters.
  96. #
  97. # @return [Hash{Symbol=>String}, nil]
  98. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  99. # @!attribute output_file_id
  100. # The ID of the file containing the outputs of successfully executed requests.
  101. #
  102. # @return [String, nil]
  103. 1 optional :output_file_id, String
  104. # @!attribute request_counts
  105. # The request counts for different statuses within the batch.
  106. #
  107. # @return [OpenAI::Models::BatchRequestCounts, nil]
  108. 1 optional :request_counts, -> { OpenAI::BatchRequestCounts }
  109. # @!method initialize(id:, completion_window:, created_at:, endpoint:, input_file_id:, status:, cancelled_at: nil, cancelling_at: nil, completed_at: nil, error_file_id: nil, errors: nil, expired_at: nil, expires_at: nil, failed_at: nil, finalizing_at: nil, in_progress_at: nil, metadata: nil, output_file_id: nil, request_counts: nil, object: :batch)
  110. # Some parameter documentations has been truncated, see {OpenAI::Models::Batch}
  111. # for more details.
  112. #
  113. # @param id [String]
  114. #
  115. # @param completion_window [String] The time frame within which the batch should be processed.
  116. #
  117. # @param created_at [Integer] The Unix timestamp (in seconds) for when the batch was created.
  118. #
  119. # @param endpoint [String] The OpenAI API endpoint used by the batch.
  120. #
  121. # @param input_file_id [String] The ID of the input file for the batch.
  122. #
  123. # @param status [Symbol, OpenAI::Models::Batch::Status] The current status of the batch.
  124. #
  125. # @param cancelled_at [Integer] The Unix timestamp (in seconds) for when the batch was cancelled.
  126. #
  127. # @param cancelling_at [Integer] The Unix timestamp (in seconds) for when the batch started cancelling.
  128. #
  129. # @param completed_at [Integer] The Unix timestamp (in seconds) for when the batch was completed.
  130. #
  131. # @param error_file_id [String] The ID of the file containing the outputs of requests with errors.
  132. #
  133. # @param errors [OpenAI::Models::Batch::Errors]
  134. #
  135. # @param expired_at [Integer] The Unix timestamp (in seconds) for when the batch expired.
  136. #
  137. # @param expires_at [Integer] The Unix timestamp (in seconds) for when the batch will expire.
  138. #
  139. # @param failed_at [Integer] The Unix timestamp (in seconds) for when the batch failed.
  140. #
  141. # @param finalizing_at [Integer] The Unix timestamp (in seconds) for when the batch started finalizing.
  142. #
  143. # @param in_progress_at [Integer] The Unix timestamp (in seconds) for when the batch started processing.
  144. #
  145. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  146. #
  147. # @param output_file_id [String] The ID of the file containing the outputs of successfully executed requests.
  148. #
  149. # @param request_counts [OpenAI::Models::BatchRequestCounts] The request counts for different statuses within the batch.
  150. #
  151. # @param object [Symbol, :batch] The object type, which is always `batch`.
  152. # The current status of the batch.
  153. #
  154. # @see OpenAI::Models::Batch#status
  155. 1 module Status
  156. 1 extend OpenAI::Internal::Type::Enum
  157. 1 VALIDATING = :validating
  158. 1 FAILED = :failed
  159. 1 IN_PROGRESS = :in_progress
  160. 1 FINALIZING = :finalizing
  161. 1 COMPLETED = :completed
  162. 1 EXPIRED = :expired
  163. 1 CANCELLING = :cancelling
  164. 1 CANCELLED = :cancelled
  165. # @!method self.values
  166. # @return [Array<Symbol>]
  167. end
  168. # @see OpenAI::Models::Batch#errors
  169. 1 class Errors < OpenAI::Internal::Type::BaseModel
  170. # @!attribute data
  171. #
  172. # @return [Array<OpenAI::Models::BatchError>, nil]
  173. 1 optional :data, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::BatchError] }
  174. # @!attribute object
  175. # The object type, which is always `list`.
  176. #
  177. # @return [String, nil]
  178. 1 optional :object, String
  179. # @!method initialize(data: nil, object: nil)
  180. # @param data [Array<OpenAI::Models::BatchError>]
  181. #
  182. # @param object [String] The object type, which is always `list`.
  183. end
  184. end
  185. end
  186. end

openai-ruby/lib/openai/models/batch_cancel_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Batches#cancel
  5. 1 class BatchCancelParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/batch_create_params.rb

100.0% lines covered

100.0% branches covered

18 relevant lines. 18 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Batches#create
  5. 1 class BatchCreateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute completion_window
  9. # The time frame within which the batch should be processed. Currently only `24h`
  10. # is supported.
  11. #
  12. # @return [Symbol, OpenAI::Models::BatchCreateParams::CompletionWindow]
  13. 1 required :completion_window, enum: -> { OpenAI::BatchCreateParams::CompletionWindow }
  14. # @!attribute endpoint
  15. # The endpoint to be used for all requests in the batch. Currently
  16. # `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions`
  17. # are supported. Note that `/v1/embeddings` batches are also restricted to a
  18. # maximum of 50,000 embedding inputs across all requests in the batch.
  19. #
  20. # @return [Symbol, OpenAI::Models::BatchCreateParams::Endpoint]
  21. 1 required :endpoint, enum: -> { OpenAI::BatchCreateParams::Endpoint }
  22. # @!attribute input_file_id
  23. # The ID of an uploaded file that contains requests for the new batch.
  24. #
  25. # See [upload file](https://platform.openai.com/docs/api-reference/files/create)
  26. # for how to upload a file.
  27. #
  28. # Your input file must be formatted as a
  29. # [JSONL file](https://platform.openai.com/docs/api-reference/batch/request-input),
  30. # and must be uploaded with the purpose `batch`. The file can contain up to 50,000
  31. # requests, and can be up to 200 MB in size.
  32. #
  33. # @return [String]
  34. 1 required :input_file_id, String
  35. # @!attribute metadata
  36. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  37. # for storing additional information about the object in a structured format, and
  38. # querying for objects via API or the dashboard.
  39. #
  40. # Keys are strings with a maximum length of 64 characters. Values are strings with
  41. # a maximum length of 512 characters.
  42. #
  43. # @return [Hash{Symbol=>String}, nil]
  44. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  45. # @!method initialize(completion_window:, endpoint:, input_file_id:, metadata: nil, request_options: {})
  46. # Some parameter documentations has been truncated, see
  47. # {OpenAI::Models::BatchCreateParams} for more details.
  48. #
  49. # @param completion_window [Symbol, OpenAI::Models::BatchCreateParams::CompletionWindow] The time frame within which the batch should be processed. Currently only `24h`
  50. #
  51. # @param endpoint [Symbol, OpenAI::Models::BatchCreateParams::Endpoint] The endpoint to be used for all requests in the batch. Currently `/v1/responses`
  52. #
  53. # @param input_file_id [String] The ID of an uploaded file that contains requests for the new batch.
  54. #
  55. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  56. #
  57. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  58. # The time frame within which the batch should be processed. Currently only `24h`
  59. # is supported.
  60. 1 module CompletionWindow
  61. 1 extend OpenAI::Internal::Type::Enum
  62. 1 COMPLETION_WINDOW_24H = :"24h"
  63. # @!method self.values
  64. # @return [Array<Symbol>]
  65. end
  66. # The endpoint to be used for all requests in the batch. Currently
  67. # `/v1/responses`, `/v1/chat/completions`, `/v1/embeddings`, and `/v1/completions`
  68. # are supported. Note that `/v1/embeddings` batches are also restricted to a
  69. # maximum of 50,000 embedding inputs across all requests in the batch.
  70. 1 module Endpoint
  71. 1 extend OpenAI::Internal::Type::Enum
  72. 1 V1_RESPONSES = :"/v1/responses"
  73. 1 V1_CHAT_COMPLETIONS = :"/v1/chat/completions"
  74. 1 V1_EMBEDDINGS = :"/v1/embeddings"
  75. 1 V1_COMPLETIONS = :"/v1/completions"
  76. # @!method self.values
  77. # @return [Array<Symbol>]
  78. end
  79. end
  80. end
  81. end

openai-ruby/lib/openai/models/batch_error.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class BatchError < OpenAI::Internal::Type::BaseModel
  5. # @!attribute code
  6. # An error code identifying the error type.
  7. #
  8. # @return [String, nil]
  9. 1 optional :code, String
  10. # @!attribute line
  11. # The line number of the input file where the error occurred, if applicable.
  12. #
  13. # @return [Integer, nil]
  14. 1 optional :line, Integer, nil?: true
  15. # @!attribute message
  16. # A human-readable message providing more details about the error.
  17. #
  18. # @return [String, nil]
  19. 1 optional :message, String
  20. # @!attribute param
  21. # The name of the parameter that caused the error, if applicable.
  22. #
  23. # @return [String, nil]
  24. 1 optional :param, String, nil?: true
  25. # @!method initialize(code: nil, line: nil, message: nil, param: nil)
  26. # @param code [String] An error code identifying the error type.
  27. #
  28. # @param line [Integer, nil] The line number of the input file where the error occurred, if applicable.
  29. #
  30. # @param message [String] A human-readable message providing more details about the error.
  31. #
  32. # @param param [String, nil] The name of the parameter that caused the error, if applicable.
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/batch_list_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Batches#list
  5. 1 class BatchListParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute after
  9. # A cursor for use in pagination. `after` is an object ID that defines your place
  10. # in the list. For instance, if you make a list request and receive 100 objects,
  11. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  12. # fetch the next page of the list.
  13. #
  14. # @return [String, nil]
  15. 1 optional :after, String
  16. # @!attribute limit
  17. # A limit on the number of objects to be returned. Limit can range between 1 and
  18. # 100, and the default is 20.
  19. #
  20. # @return [Integer, nil]
  21. 1 optional :limit, Integer
  22. # @!method initialize(after: nil, limit: nil, request_options: {})
  23. # Some parameter documentations has been truncated, see
  24. # {OpenAI::Models::BatchListParams} for more details.
  25. #
  26. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  27. #
  28. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  29. #
  30. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  31. end
  32. end
  33. end

openai-ruby/lib/openai/models/batch_request_counts.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class BatchRequestCounts < OpenAI::Internal::Type::BaseModel
  5. # @!attribute completed
  6. # Number of requests that have been completed successfully.
  7. #
  8. # @return [Integer]
  9. 1 required :completed, Integer
  10. # @!attribute failed
  11. # Number of requests that have failed.
  12. #
  13. # @return [Integer]
  14. 1 required :failed, Integer
  15. # @!attribute total
  16. # Total number of requests in the batch.
  17. #
  18. # @return [Integer]
  19. 1 required :total, Integer
  20. # @!method initialize(completed:, failed:, total:)
  21. # The request counts for different statuses within the batch.
  22. #
  23. # @param completed [Integer] Number of requests that have been completed successfully.
  24. #
  25. # @param failed [Integer] Number of requests that have failed.
  26. #
  27. # @param total [Integer] Total number of requests in the batch.
  28. end
  29. end
  30. end

openai-ruby/lib/openai/models/batch_retrieve_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Batches#retrieve
  5. 1 class BatchRetrieveParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/beta/assistant.rb

100.0% lines covered

100.0% branches covered

24 relevant lines. 24 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Assistants#create
  6. 1 class Assistant < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The identifier, which can be referenced in API endpoints.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # The Unix timestamp (in seconds) for when the assistant was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute description
  18. # The description of the assistant. The maximum length is 512 characters.
  19. #
  20. # @return [String, nil]
  21. 1 required :description, String, nil?: true
  22. # @!attribute instructions
  23. # The system instructions that the assistant uses. The maximum length is 256,000
  24. # characters.
  25. #
  26. # @return [String, nil]
  27. 1 required :instructions, String, nil?: true
  28. # @!attribute metadata
  29. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  30. # for storing additional information about the object in a structured format, and
  31. # querying for objects via API or the dashboard.
  32. #
  33. # Keys are strings with a maximum length of 64 characters. Values are strings with
  34. # a maximum length of 512 characters.
  35. #
  36. # @return [Hash{Symbol=>String}, nil]
  37. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  38. # @!attribute model
  39. # ID of the model to use. You can use the
  40. # [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  41. # see all of your available models, or see our
  42. # [Model overview](https://platform.openai.com/docs/models) for descriptions of
  43. # them.
  44. #
  45. # @return [String]
  46. 1 required :model, String
  47. # @!attribute name
  48. # The name of the assistant. The maximum length is 256 characters.
  49. #
  50. # @return [String, nil]
  51. 1 required :name, String, nil?: true
  52. # @!attribute object
  53. # The object type, which is always `assistant`.
  54. #
  55. # @return [Symbol, :assistant]
  56. 1 required :object, const: :assistant
  57. # @!attribute tools
  58. # A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  59. # assistant. Tools can be of types `code_interpreter`, `file_search`, or
  60. # `function`.
  61. #
  62. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>]
  63. 1 required :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::AssistantTool] }
  64. # @!attribute response_format
  65. # Specifies the format that the model must output. Compatible with
  66. # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  67. # [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  68. # and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  69. #
  70. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  71. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  72. # in the
  73. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  74. #
  75. # Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  76. # message the model generates is valid JSON.
  77. #
  78. # **Important:** when using JSON mode, you **must** also instruct the model to
  79. # produce JSON yourself via a system or user message. Without this, the model may
  80. # generate an unending stream of whitespace until the generation reaches the token
  81. # limit, resulting in a long-running and seemingly "stuck" request. Also note that
  82. # the message content may be partially cut off if `finish_reason="length"`, which
  83. # indicates the generation exceeded `max_tokens` or the conversation exceeded the
  84. # max context length.
  85. #
  86. # @return [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil]
  87. 1 optional :response_format, union: -> { OpenAI::Beta::AssistantResponseFormatOption }, nil?: true
  88. # @!attribute temperature
  89. # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  90. # make the output more random, while lower values like 0.2 will make it more
  91. # focused and deterministic.
  92. #
  93. # @return [Float, nil]
  94. 1 optional :temperature, Float, nil?: true
  95. # @!attribute tool_resources
  96. # A set of resources that are used by the assistant's tools. The resources are
  97. # specific to the type of tool. For example, the `code_interpreter` tool requires
  98. # a list of file IDs, while the `file_search` tool requires a list of vector store
  99. # IDs.
  100. #
  101. # @return [OpenAI::Models::Beta::Assistant::ToolResources, nil]
  102. 1 optional :tool_resources, -> { OpenAI::Beta::Assistant::ToolResources }, nil?: true
  103. # @!attribute top_p
  104. # An alternative to sampling with temperature, called nucleus sampling, where the
  105. # model considers the results of the tokens with top_p probability mass. So 0.1
  106. # means only the tokens comprising the top 10% probability mass are considered.
  107. #
  108. # We generally recommend altering this or temperature but not both.
  109. #
  110. # @return [Float, nil]
  111. 1 optional :top_p, Float, nil?: true
  112. # @!method initialize(id:, created_at:, description:, instructions:, metadata:, model:, name:, tools:, response_format: nil, temperature: nil, tool_resources: nil, top_p: nil, object: :assistant)
  113. # Some parameter documentations has been truncated, see
  114. # {OpenAI::Models::Beta::Assistant} for more details.
  115. #
  116. # Represents an `assistant` that can call the model and use tools.
  117. #
  118. # @param id [String] The identifier, which can be referenced in API endpoints.
  119. #
  120. # @param created_at [Integer] The Unix timestamp (in seconds) for when the assistant was created.
  121. #
  122. # @param description [String, nil] The description of the assistant. The maximum length is 512 characters.
  123. #
  124. # @param instructions [String, nil] The system instructions that the assistant uses. The maximum length is 256,000 c
  125. #
  126. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  127. #
  128. # @param model [String] ID of the model to use. You can use the [List models](https://platform.openai.co
  129. #
  130. # @param name [String, nil] The name of the assistant. The maximum length is 256 characters.
  131. #
  132. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>] A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  133. #
  134. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  135. #
  136. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  137. #
  138. # @param tool_resources [OpenAI::Models::Beta::Assistant::ToolResources, nil] A set of resources that are used by the assistant's tools. The resources are spe
  139. #
  140. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  141. #
  142. # @param object [Symbol, :assistant] The object type, which is always `assistant`.
  143. # @see OpenAI::Models::Beta::Assistant#tool_resources
  144. 1 class ToolResources < OpenAI::Internal::Type::BaseModel
  145. # @!attribute code_interpreter
  146. #
  147. # @return [OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter, nil]
  148. 1 optional :code_interpreter, -> { OpenAI::Beta::Assistant::ToolResources::CodeInterpreter }
  149. # @!attribute file_search
  150. #
  151. # @return [OpenAI::Models::Beta::Assistant::ToolResources::FileSearch, nil]
  152. 1 optional :file_search, -> { OpenAI::Beta::Assistant::ToolResources::FileSearch }
  153. # @!method initialize(code_interpreter: nil, file_search: nil)
  154. # A set of resources that are used by the assistant's tools. The resources are
  155. # specific to the type of tool. For example, the `code_interpreter` tool requires
  156. # a list of file IDs, while the `file_search` tool requires a list of vector store
  157. # IDs.
  158. #
  159. # @param code_interpreter [OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter]
  160. # @param file_search [OpenAI::Models::Beta::Assistant::ToolResources::FileSearch]
  161. # @see OpenAI::Models::Beta::Assistant::ToolResources#code_interpreter
  162. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  163. # @!attribute file_ids
  164. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  165. # available to the `code_interpreter`` tool. There can be a maximum of 20 files
  166. # associated with the tool.
  167. #
  168. # @return [Array<String>, nil]
  169. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  170. # @!method initialize(file_ids: nil)
  171. # Some parameter documentations has been truncated, see
  172. # {OpenAI::Models::Beta::Assistant::ToolResources::CodeInterpreter} for more
  173. # details.
  174. #
  175. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  176. end
  177. # @see OpenAI::Models::Beta::Assistant::ToolResources#file_search
  178. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  179. # @!attribute vector_store_ids
  180. # The ID of the
  181. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  182. # attached to this assistant. There can be a maximum of 1 vector store attached to
  183. # the assistant.
  184. #
  185. # @return [Array<String>, nil]
  186. 1 optional :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]
  187. # @!method initialize(vector_store_ids: nil)
  188. # Some parameter documentations has been truncated, see
  189. # {OpenAI::Models::Beta::Assistant::ToolResources::FileSearch} for more details.
  190. #
  191. # @param vector_store_ids [Array<String>] The ID of the [vector store](https://platform.openai.com/docs/api-reference/vect
  192. end
  193. end
  194. end
  195. end
  196. end
  197. end

openai-ruby/lib/openai/models/beta/assistant_create_params.rb

88.46% lines covered

100.0% branches covered

52 relevant lines. 46 lines covered and 6 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Assistants#create
  6. 1 class AssistantCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute model
  10. # ID of the model to use. You can use the
  11. # [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  12. # see all of your available models, or see our
  13. # [Model overview](https://platform.openai.com/docs/models) for descriptions of
  14. # them.
  15. #
  16. # @return [String, Symbol, OpenAI::Models::ChatModel]
  17. 1 required :model, union: -> { OpenAI::Beta::AssistantCreateParams::Model }
  18. # @!attribute description
  19. # The description of the assistant. The maximum length is 512 characters.
  20. #
  21. # @return [String, nil]
  22. 1 optional :description, String, nil?: true
  23. # @!attribute instructions
  24. # The system instructions that the assistant uses. The maximum length is 256,000
  25. # characters.
  26. #
  27. # @return [String, nil]
  28. 1 optional :instructions, String, nil?: true
  29. # @!attribute metadata
  30. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  31. # for storing additional information about the object in a structured format, and
  32. # querying for objects via API or the dashboard.
  33. #
  34. # Keys are strings with a maximum length of 64 characters. Values are strings with
  35. # a maximum length of 512 characters.
  36. #
  37. # @return [Hash{Symbol=>String}, nil]
  38. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  39. # @!attribute name
  40. # The name of the assistant. The maximum length is 256 characters.
  41. #
  42. # @return [String, nil]
  43. 1 optional :name, String, nil?: true
  44. # @!attribute reasoning_effort
  45. # **o-series models only**
  46. #
  47. # Constrains effort on reasoning for
  48. # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
  49. # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
  50. # result in faster responses and fewer tokens used on reasoning in a response.
  51. #
  52. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  53. 1 optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  54. # @!attribute response_format
  55. # Specifies the format that the model must output. Compatible with
  56. # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  57. # [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  58. # and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  59. #
  60. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  61. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  62. # in the
  63. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  64. #
  65. # Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  66. # message the model generates is valid JSON.
  67. #
  68. # **Important:** when using JSON mode, you **must** also instruct the model to
  69. # produce JSON yourself via a system or user message. Without this, the model may
  70. # generate an unending stream of whitespace until the generation reaches the token
  71. # limit, resulting in a long-running and seemingly "stuck" request. Also note that
  72. # the message content may be partially cut off if `finish_reason="length"`, which
  73. # indicates the generation exceeded `max_tokens` or the conversation exceeded the
  74. # max context length.
  75. #
  76. # @return [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil]
  77. 1 optional :response_format, union: -> { OpenAI::Beta::AssistantResponseFormatOption }, nil?: true
  78. # @!attribute temperature
  79. # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  80. # make the output more random, while lower values like 0.2 will make it more
  81. # focused and deterministic.
  82. #
  83. # @return [Float, nil]
  84. 1 optional :temperature, Float, nil?: true
  85. # @!attribute tool_resources
  86. # A set of resources that are used by the assistant's tools. The resources are
  87. # specific to the type of tool. For example, the `code_interpreter` tool requires
  88. # a list of file IDs, while the `file_search` tool requires a list of vector store
  89. # IDs.
  90. #
  91. # @return [OpenAI::Models::Beta::AssistantCreateParams::ToolResources, nil]
  92. 1 optional :tool_resources, -> { OpenAI::Beta::AssistantCreateParams::ToolResources }, nil?: true
  93. # @!attribute tools
  94. # A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  95. # assistant. Tools can be of types `code_interpreter`, `file_search`, or
  96. # `function`.
  97. #
  98. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil]
  99. 1 optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::AssistantTool] }
  100. # @!attribute top_p
  101. # An alternative to sampling with temperature, called nucleus sampling, where the
  102. # model considers the results of the tokens with top_p probability mass. So 0.1
  103. # means only the tokens comprising the top 10% probability mass are considered.
  104. #
  105. # We generally recommend altering this or temperature but not both.
  106. #
  107. # @return [Float, nil]
  108. 1 optional :top_p, Float, nil?: true
  109. # @!method initialize(model:, description: nil, instructions: nil, metadata: nil, name: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_resources: nil, tools: nil, top_p: nil, request_options: {})
  110. # Some parameter documentations has been truncated, see
  111. # {OpenAI::Models::Beta::AssistantCreateParams} for more details.
  112. #
  113. # @param model [String, Symbol, OpenAI::Models::ChatModel] ID of the model to use. You can use the [List models](https://platform.openai.co
  114. #
  115. # @param description [String, nil] The description of the assistant. The maximum length is 512 characters.
  116. #
  117. # @param instructions [String, nil] The system instructions that the assistant uses. The maximum length is 256,000 c
  118. #
  119. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  120. #
  121. # @param name [String, nil] The name of the assistant. The maximum length is 256 characters.
  122. #
  123. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] **o-series models only**
  124. #
  125. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  126. #
  127. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  128. #
  129. # @param tool_resources [OpenAI::Models::Beta::AssistantCreateParams::ToolResources, nil] A set of resources that are used by the assistant's tools. The resources are spe
  130. #
  131. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>] A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  132. #
  133. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  134. #
  135. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  136. # ID of the model to use. You can use the
  137. # [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  138. # see all of your available models, or see our
  139. # [Model overview](https://platform.openai.com/docs/models) for descriptions of
  140. # them.
  141. 1 module Model
  142. 1 extend OpenAI::Internal::Type::Union
  143. 1 variant String
  144. # ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.
  145. 1 variant enum: -> { OpenAI::ChatModel }
  146. # @!method self.variants
  147. # @return [Array(String, Symbol, OpenAI::Models::ChatModel)]
  148. end
  149. 1 class ToolResources < OpenAI::Internal::Type::BaseModel
  150. # @!attribute code_interpreter
  151. #
  152. # @return [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter, nil]
  153. 1 optional :code_interpreter,
  154. -> {
  155. OpenAI::Beta::AssistantCreateParams::ToolResources::CodeInterpreter
  156. }
  157. # @!attribute file_search
  158. #
  159. # @return [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch, nil]
  160. 1 optional :file_search, -> { OpenAI::Beta::AssistantCreateParams::ToolResources::FileSearch }
  161. # @!method initialize(code_interpreter: nil, file_search: nil)
  162. # A set of resources that are used by the assistant's tools. The resources are
  163. # specific to the type of tool. For example, the `code_interpreter` tool requires
  164. # a list of file IDs, while the `file_search` tool requires a list of vector store
  165. # IDs.
  166. #
  167. # @param code_interpreter [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter]
  168. # @param file_search [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch]
  169. # @see OpenAI::Models::Beta::AssistantCreateParams::ToolResources#code_interpreter
  170. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  171. # @!attribute file_ids
  172. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  173. # available to the `code_interpreter` tool. There can be a maximum of 20 files
  174. # associated with the tool.
  175. #
  176. # @return [Array<String>, nil]
  177. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  178. # @!method initialize(file_ids: nil)
  179. # Some parameter documentations has been truncated, see
  180. # {OpenAI::Models::Beta::AssistantCreateParams::ToolResources::CodeInterpreter}
  181. # for more details.
  182. #
  183. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  184. end
  185. # @see OpenAI::Models::Beta::AssistantCreateParams::ToolResources#file_search
  186. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  187. # @!attribute vector_store_ids
  188. # The
  189. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  190. # attached to this assistant. There can be a maximum of 1 vector store attached to
  191. # the assistant.
  192. #
  193. # @return [Array<String>, nil]
  194. 1 optional :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]
  195. # @!attribute vector_stores
  196. # A helper to create a
  197. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  198. # with file_ids and attach it to this assistant. There can be a maximum of 1
  199. # vector store attached to the assistant.
  200. #
  201. # @return [Array<OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore>, nil]
  202. 1 optional :vector_stores,
  203. -> {
  204. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore]
  205. }
  206. # @!method initialize(vector_store_ids: nil, vector_stores: nil)
  207. # Some parameter documentations has been truncated, see
  208. # {OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch} for
  209. # more details.
  210. #
  211. # @param vector_store_ids [Array<String>] The [vector store](https://platform.openai.com/docs/api-reference/vector-stores/
  212. #
  213. # @param vector_stores [Array<OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore>] A helper to create a [vector store](https://platform.openai.com/docs/api-referen
  214. 1 class VectorStore < OpenAI::Internal::Type::BaseModel
  215. # @!attribute chunking_strategy
  216. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  217. # strategy.
  218. #
  219. # @return [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static, nil]
  220. 1 optional :chunking_strategy,
  221. union: -> {
  222. OpenAI::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy
  223. }
  224. # @!attribute file_ids
  225. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
  226. # add to the vector store. There can be a maximum of 10000 files in a vector
  227. # store.
  228. #
  229. # @return [Array<String>, nil]
  230. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  231. # @!attribute metadata
  232. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  233. # for storing additional information about the object in a structured format, and
  234. # querying for objects via API or the dashboard.
  235. #
  236. # Keys are strings with a maximum length of 64 characters. Values are strings with
  237. # a maximum length of 512 characters.
  238. #
  239. # @return [Hash{Symbol=>String}, nil]
  240. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  241. # @!method initialize(chunking_strategy: nil, file_ids: nil, metadata: nil)
  242. # Some parameter documentations has been truncated, see
  243. # {OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore}
  244. # for more details.
  245. #
  246. # @param chunking_strategy [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  247. #
  248. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to ad
  249. #
  250. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  251. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  252. # strategy.
  253. #
  254. # @see OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore#chunking_strategy
  255. 1 module ChunkingStrategy
  256. 1 extend OpenAI::Internal::Type::Union
  257. 1 discriminator :type
  258. # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
  259. 1 variant :auto,
  260. -> {
  261. OpenAI::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto
  262. }
  263. 1 variant :static,
  264. -> {
  265. OpenAI::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static
  266. }
  267. 1 class Auto < OpenAI::Internal::Type::BaseModel
  268. # @!attribute type
  269. # Always `auto`.
  270. #
  271. # @return [Symbol, :auto]
  272. 1 required :type, const: :auto
  273. # @!method initialize(type: :auto)
  274. # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
  275. # `800` and `chunk_overlap_tokens` of `400`.
  276. #
  277. # @param type [Symbol, :auto] Always `auto`.
  278. end
  279. 1 class Static < OpenAI::Internal::Type::BaseModel
  280. # @!attribute static
  281. #
  282. # @return [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static]
  283. 1 required :static,
  284. -> {
  285. OpenAI::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static
  286. }
  287. # @!attribute type
  288. # Always `static`.
  289. #
  290. # @return [Symbol, :static]
  291. 1 required :type, const: :static
  292. # @!method initialize(static:, type: :static)
  293. # @param static [OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static]
  294. #
  295. # @param type [Symbol, :static] Always `static`.
  296. # @see OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static#static
  297. 1 class Static < OpenAI::Internal::Type::BaseModel
  298. # @!attribute chunk_overlap_tokens
  299. # The number of tokens that overlap between chunks. The default value is `400`.
  300. #
  301. # Note that the overlap must not exceed half of `max_chunk_size_tokens`.
  302. #
  303. # @return [Integer]
  304. 1 required :chunk_overlap_tokens, Integer
  305. # @!attribute max_chunk_size_tokens
  306. # The maximum number of tokens in each chunk. The default value is `800`. The
  307. # minimum value is `100` and the maximum value is `4096`.
  308. #
  309. # @return [Integer]
  310. 1 required :max_chunk_size_tokens, Integer
  311. # @!method initialize(chunk_overlap_tokens:, max_chunk_size_tokens:)
  312. # Some parameter documentations has been truncated, see
  313. # {OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static}
  314. # for more details.
  315. #
  316. # @param chunk_overlap_tokens [Integer] The number of tokens that overlap between chunks. The default value is `400`.
  317. #
  318. # @param max_chunk_size_tokens [Integer] The maximum number of tokens in each chunk. The default value is `800`. The mini
  319. end
  320. end
  321. # @!method self.variants
  322. # @return [Array(OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::AssistantCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)]
  323. end
  324. end
  325. end
  326. end
  327. end
  328. end
  329. end
  330. end

openai-ruby/lib/openai/models/beta/assistant_delete_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Assistants#delete
  6. 1 class AssistantDeleteParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/beta/assistant_deleted.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Assistants#delete
  6. 1 class AssistantDeleted < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute deleted
  12. #
  13. # @return [Boolean]
  14. 1 required :deleted, OpenAI::Internal::Type::Boolean
  15. # @!attribute object
  16. #
  17. # @return [Symbol, :"assistant.deleted"]
  18. 1 required :object, const: :"assistant.deleted"
  19. # @!method initialize(id:, deleted:, object: :"assistant.deleted")
  20. # @param id [String]
  21. # @param deleted [Boolean]
  22. # @param object [Symbol, :"assistant.deleted"]
  23. end
  24. end
  25. end
  26. end

openai-ruby/lib/openai/models/beta/assistant_list_params.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Assistants#list
  6. 1 class AssistantListParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute after
  10. # A cursor for use in pagination. `after` is an object ID that defines your place
  11. # in the list. For instance, if you make a list request and receive 100 objects,
  12. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  13. # fetch the next page of the list.
  14. #
  15. # @return [String, nil]
  16. 1 optional :after, String
  17. # @!attribute before
  18. # A cursor for use in pagination. `before` is an object ID that defines your place
  19. # in the list. For instance, if you make a list request and receive 100 objects,
  20. # starting with obj_foo, your subsequent call can include before=obj_foo in order
  21. # to fetch the previous page of the list.
  22. #
  23. # @return [String, nil]
  24. 1 optional :before, String
  25. # @!attribute limit
  26. # A limit on the number of objects to be returned. Limit can range between 1 and
  27. # 100, and the default is 20.
  28. #
  29. # @return [Integer, nil]
  30. 1 optional :limit, Integer
  31. # @!attribute order
  32. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  33. # order and `desc` for descending order.
  34. #
  35. # @return [Symbol, OpenAI::Models::Beta::AssistantListParams::Order, nil]
  36. 1 optional :order, enum: -> { OpenAI::Beta::AssistantListParams::Order }
  37. # @!method initialize(after: nil, before: nil, limit: nil, order: nil, request_options: {})
  38. # Some parameter documentations has been truncated, see
  39. # {OpenAI::Models::Beta::AssistantListParams} for more details.
  40. #
  41. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  42. #
  43. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  44. #
  45. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  46. #
  47. # @param order [Symbol, OpenAI::Models::Beta::AssistantListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  48. #
  49. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  50. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  51. # order and `desc` for descending order.
  52. 1 module Order
  53. 1 extend OpenAI::Internal::Type::Enum
  54. 1 ASC = :asc
  55. 1 DESC = :desc
  56. # @!method self.values
  57. # @return [Array<Symbol>]
  58. end
  59. end
  60. end
  61. end
  62. end

openai-ruby/lib/openai/models/beta/assistant_response_format_option.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # Specifies the format that the model must output. Compatible with
  6. # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  7. # [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  8. # and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  9. #
  10. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  11. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  12. # in the
  13. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  14. #
  15. # Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  16. # message the model generates is valid JSON.
  17. #
  18. # **Important:** when using JSON mode, you **must** also instruct the model to
  19. # produce JSON yourself via a system or user message. Without this, the model may
  20. # generate an unending stream of whitespace until the generation reaches the token
  21. # limit, resulting in a long-running and seemingly "stuck" request. Also note that
  22. # the message content may be partially cut off if `finish_reason="length"`, which
  23. # indicates the generation exceeded `max_tokens` or the conversation exceeded the
  24. # max context length.
  25. 1 module AssistantResponseFormatOption
  26. 1 extend OpenAI::Internal::Type::Union
  27. # `auto` is the default value
  28. 1 variant const: :auto
  29. # Default response format. Used to generate text responses.
  30. 1 variant -> { OpenAI::ResponseFormatText }
  31. # JSON object response format. An older method of generating JSON responses.
  32. # Using `json_schema` is recommended for models that support it. Note that the
  33. # model will not generate JSON without a system or user message instructing it
  34. # to do so.
  35. 1 variant -> { OpenAI::ResponseFormatJSONObject }
  36. # JSON Schema response format. Used to generate structured JSON responses.
  37. # Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
  38. 1 variant -> { OpenAI::ResponseFormatJSONSchema }
  39. # @!method self.variants
  40. # @return [Array(Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema)]
  41. end
  42. end
  43. end
  44. end

openai-ruby/lib/openai/models/beta/assistant_retrieve_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Assistants#retrieve
  6. 1 class AssistantRetrieveParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/beta/assistant_stream_event.rb

94.5% lines covered

100.0% branches covered

109 relevant lines. 103 lines covered and 6 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # Represents an event emitted when streaming a Run.
  6. #
  7. # Each event in a server-sent events stream has an `event` and `data` property:
  8. #
  9. # ```
  10. # event: thread.created
  11. # data: {"id": "thread_123", "object": "thread", ...}
  12. # ```
  13. #
  14. # We emit events whenever a new object is created, transitions to a new state, or
  15. # is being streamed in parts (deltas). For example, we emit `thread.run.created`
  16. # when a new run is created, `thread.run.completed` when a run completes, and so
  17. # on. When an Assistant chooses to create a message during a run, we emit a
  18. # `thread.message.created event`, a `thread.message.in_progress` event, many
  19. # `thread.message.delta` events, and finally a `thread.message.completed` event.
  20. #
  21. # We may add additional events over time, so we recommend handling unknown events
  22. # gracefully in your code. See the
  23. # [Assistants API quickstart](https://platform.openai.com/docs/assistants/overview)
  24. # to learn how to integrate the Assistants API with streaming.
  25. 1 module AssistantStreamEvent
  26. 1 extend OpenAI::Internal::Type::Union
  27. 1 discriminator :event
  28. # Occurs when a new [thread](https://platform.openai.com/docs/api-reference/threads/object) is created.
  29. 1 variant :"thread.created", -> { OpenAI::Beta::AssistantStreamEvent::ThreadCreated }
  30. # Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
  31. 1 variant :"thread.run.created", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunCreated }
  32. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `queued` status.
  33. 1 variant :"thread.run.queued", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunQueued }
  34. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to an `in_progress` status.
  35. 1 variant :"thread.run.in_progress", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunInProgress }
  36. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `requires_action` status.
  37. 1 variant :"thread.run.requires_action",
  38. -> {
  39. OpenAI::Beta::AssistantStreamEvent::ThreadRunRequiresAction
  40. }
  41. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is completed.
  42. 1 variant :"thread.run.completed", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunCompleted }
  43. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) ends with status `incomplete`.
  44. 1 variant :"thread.run.incomplete", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunIncomplete }
  45. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) fails.
  46. 1 variant :"thread.run.failed", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunFailed }
  47. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `cancelling` status.
  48. 1 variant :"thread.run.cancelling", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunCancelling }
  49. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is cancelled.
  50. 1 variant :"thread.run.cancelled", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunCancelled }
  51. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) expires.
  52. 1 variant :"thread.run.expired", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunExpired }
  53. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is created.
  54. 1 variant :"thread.run.step.created", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunStepCreated }
  55. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) moves to an `in_progress` state.
  56. 1 variant :"thread.run.step.in_progress",
  57. -> {
  58. OpenAI::Beta::AssistantStreamEvent::ThreadRunStepInProgress
  59. }
  60. # Occurs when parts of a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) are being streamed.
  61. 1 variant :"thread.run.step.delta", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunStepDelta }
  62. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is completed.
  63. 1 variant :"thread.run.step.completed",
  64. -> {
  65. OpenAI::Beta::AssistantStreamEvent::ThreadRunStepCompleted
  66. }
  67. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) fails.
  68. 1 variant :"thread.run.step.failed", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunStepFailed }
  69. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is cancelled.
  70. 1 variant :"thread.run.step.cancelled",
  71. -> {
  72. OpenAI::Beta::AssistantStreamEvent::ThreadRunStepCancelled
  73. }
  74. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) expires.
  75. 1 variant :"thread.run.step.expired", -> { OpenAI::Beta::AssistantStreamEvent::ThreadRunStepExpired }
  76. # Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created.
  77. 1 variant :"thread.message.created", -> { OpenAI::Beta::AssistantStreamEvent::ThreadMessageCreated }
  78. # Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) moves to an `in_progress` state.
  79. 1 variant :"thread.message.in_progress",
  80. -> {
  81. OpenAI::Beta::AssistantStreamEvent::ThreadMessageInProgress
  82. }
  83. # Occurs when parts of a [Message](https://platform.openai.com/docs/api-reference/messages/object) are being streamed.
  84. 1 variant :"thread.message.delta", -> { OpenAI::Beta::AssistantStreamEvent::ThreadMessageDelta }
  85. # Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is completed.
  86. 1 variant :"thread.message.completed", -> { OpenAI::Beta::AssistantStreamEvent::ThreadMessageCompleted }
  87. # Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) ends before it is completed.
  88. 1 variant :"thread.message.incomplete",
  89. -> {
  90. OpenAI::Beta::AssistantStreamEvent::ThreadMessageIncomplete
  91. }
  92. # Occurs when an [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs. This can happen due to an internal server error or a timeout.
  93. 1 variant :error, -> { OpenAI::Beta::AssistantStreamEvent::ErrorEvent }
  94. 1 class ThreadCreated < OpenAI::Internal::Type::BaseModel
  95. # @!attribute data
  96. # Represents a thread that contains
  97. # [messages](https://platform.openai.com/docs/api-reference/messages).
  98. #
  99. # @return [OpenAI::Models::Beta::Thread]
  100. 1 required :data, -> { OpenAI::Beta::Thread }
  101. # @!attribute event
  102. #
  103. # @return [Symbol, :"thread.created"]
  104. 1 required :event, const: :"thread.created"
  105. # @!attribute enabled
  106. # Whether to enable input audio transcription.
  107. #
  108. # @return [Boolean, nil]
  109. 1 optional :enabled, OpenAI::Internal::Type::Boolean
  110. # @!method initialize(data:, enabled: nil, event: :"thread.created")
  111. # Some parameter documentations has been truncated, see
  112. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated} for more details.
  113. #
  114. # Occurs when a new
  115. # [thread](https://platform.openai.com/docs/api-reference/threads/object) is
  116. # created.
  117. #
  118. # @param data [OpenAI::Models::Beta::Thread] Represents a thread that contains [messages](https://platform.openai.com/docs/ap
  119. #
  120. # @param enabled [Boolean] Whether to enable input audio transcription.
  121. #
  122. # @param event [Symbol, :"thread.created"]
  123. end
  124. 1 class ThreadRunCreated < OpenAI::Internal::Type::BaseModel
  125. # @!attribute data
  126. # Represents an execution run on a
  127. # [thread](https://platform.openai.com/docs/api-reference/threads).
  128. #
  129. # @return [OpenAI::Models::Beta::Threads::Run]
  130. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  131. # @!attribute event
  132. #
  133. # @return [Symbol, :"thread.run.created"]
  134. 1 required :event, const: :"thread.run.created"
  135. # @!method initialize(data:, event: :"thread.run.created")
  136. # Some parameter documentations has been truncated, see
  137. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated} for more details.
  138. #
  139. # Occurs when a new
  140. # [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
  141. #
  142. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  143. #
  144. # @param event [Symbol, :"thread.run.created"]
  145. end
  146. 1 class ThreadRunQueued < OpenAI::Internal::Type::BaseModel
  147. # @!attribute data
  148. # Represents an execution run on a
  149. # [thread](https://platform.openai.com/docs/api-reference/threads).
  150. #
  151. # @return [OpenAI::Models::Beta::Threads::Run]
  152. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  153. # @!attribute event
  154. #
  155. # @return [Symbol, :"thread.run.queued"]
  156. 1 required :event, const: :"thread.run.queued"
  157. # @!method initialize(data:, event: :"thread.run.queued")
  158. # Some parameter documentations has been truncated, see
  159. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued} for more details.
  160. #
  161. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  162. # moves to a `queued` status.
  163. #
  164. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  165. #
  166. # @param event [Symbol, :"thread.run.queued"]
  167. end
  168. 1 class ThreadRunInProgress < OpenAI::Internal::Type::BaseModel
  169. # @!attribute data
  170. # Represents an execution run on a
  171. # [thread](https://platform.openai.com/docs/api-reference/threads).
  172. #
  173. # @return [OpenAI::Models::Beta::Threads::Run]
  174. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  175. # @!attribute event
  176. #
  177. # @return [Symbol, :"thread.run.in_progress"]
  178. 1 required :event, const: :"thread.run.in_progress"
  179. # @!method initialize(data:, event: :"thread.run.in_progress")
  180. # Some parameter documentations has been truncated, see
  181. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress} for more
  182. # details.
  183. #
  184. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  185. # moves to an `in_progress` status.
  186. #
  187. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  188. #
  189. # @param event [Symbol, :"thread.run.in_progress"]
  190. end
  191. 1 class ThreadRunRequiresAction < OpenAI::Internal::Type::BaseModel
  192. # @!attribute data
  193. # Represents an execution run on a
  194. # [thread](https://platform.openai.com/docs/api-reference/threads).
  195. #
  196. # @return [OpenAI::Models::Beta::Threads::Run]
  197. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  198. # @!attribute event
  199. #
  200. # @return [Symbol, :"thread.run.requires_action"]
  201. 1 required :event, const: :"thread.run.requires_action"
  202. # @!method initialize(data:, event: :"thread.run.requires_action")
  203. # Some parameter documentations has been truncated, see
  204. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction} for more
  205. # details.
  206. #
  207. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  208. # moves to a `requires_action` status.
  209. #
  210. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  211. #
  212. # @param event [Symbol, :"thread.run.requires_action"]
  213. end
  214. 1 class ThreadRunCompleted < OpenAI::Internal::Type::BaseModel
  215. # @!attribute data
  216. # Represents an execution run on a
  217. # [thread](https://platform.openai.com/docs/api-reference/threads).
  218. #
  219. # @return [OpenAI::Models::Beta::Threads::Run]
  220. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  221. # @!attribute event
  222. #
  223. # @return [Symbol, :"thread.run.completed"]
  224. 1 required :event, const: :"thread.run.completed"
  225. # @!method initialize(data:, event: :"thread.run.completed")
  226. # Some parameter documentations has been truncated, see
  227. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted} for more
  228. # details.
  229. #
  230. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  231. # is completed.
  232. #
  233. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  234. #
  235. # @param event [Symbol, :"thread.run.completed"]
  236. end
  237. 1 class ThreadRunIncomplete < OpenAI::Internal::Type::BaseModel
  238. # @!attribute data
  239. # Represents an execution run on a
  240. # [thread](https://platform.openai.com/docs/api-reference/threads).
  241. #
  242. # @return [OpenAI::Models::Beta::Threads::Run]
  243. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  244. # @!attribute event
  245. #
  246. # @return [Symbol, :"thread.run.incomplete"]
  247. 1 required :event, const: :"thread.run.incomplete"
  248. # @!method initialize(data:, event: :"thread.run.incomplete")
  249. # Some parameter documentations has been truncated, see
  250. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete} for more
  251. # details.
  252. #
  253. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  254. # ends with status `incomplete`.
  255. #
  256. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  257. #
  258. # @param event [Symbol, :"thread.run.incomplete"]
  259. end
  260. 1 class ThreadRunFailed < OpenAI::Internal::Type::BaseModel
  261. # @!attribute data
  262. # Represents an execution run on a
  263. # [thread](https://platform.openai.com/docs/api-reference/threads).
  264. #
  265. # @return [OpenAI::Models::Beta::Threads::Run]
  266. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  267. # @!attribute event
  268. #
  269. # @return [Symbol, :"thread.run.failed"]
  270. 1 required :event, const: :"thread.run.failed"
  271. # @!method initialize(data:, event: :"thread.run.failed")
  272. # Some parameter documentations has been truncated, see
  273. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed} for more details.
  274. #
  275. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  276. # fails.
  277. #
  278. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  279. #
  280. # @param event [Symbol, :"thread.run.failed"]
  281. end
  282. 1 class ThreadRunCancelling < OpenAI::Internal::Type::BaseModel
  283. # @!attribute data
  284. # Represents an execution run on a
  285. # [thread](https://platform.openai.com/docs/api-reference/threads).
  286. #
  287. # @return [OpenAI::Models::Beta::Threads::Run]
  288. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  289. # @!attribute event
  290. #
  291. # @return [Symbol, :"thread.run.cancelling"]
  292. 1 required :event, const: :"thread.run.cancelling"
  293. # @!method initialize(data:, event: :"thread.run.cancelling")
  294. # Some parameter documentations has been truncated, see
  295. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling} for more
  296. # details.
  297. #
  298. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  299. # moves to a `cancelling` status.
  300. #
  301. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  302. #
  303. # @param event [Symbol, :"thread.run.cancelling"]
  304. end
  305. 1 class ThreadRunCancelled < OpenAI::Internal::Type::BaseModel
  306. # @!attribute data
  307. # Represents an execution run on a
  308. # [thread](https://platform.openai.com/docs/api-reference/threads).
  309. #
  310. # @return [OpenAI::Models::Beta::Threads::Run]
  311. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  312. # @!attribute event
  313. #
  314. # @return [Symbol, :"thread.run.cancelled"]
  315. 1 required :event, const: :"thread.run.cancelled"
  316. # @!method initialize(data:, event: :"thread.run.cancelled")
  317. # Some parameter documentations has been truncated, see
  318. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled} for more
  319. # details.
  320. #
  321. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  322. # is cancelled.
  323. #
  324. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  325. #
  326. # @param event [Symbol, :"thread.run.cancelled"]
  327. end
  328. 1 class ThreadRunExpired < OpenAI::Internal::Type::BaseModel
  329. # @!attribute data
  330. # Represents an execution run on a
  331. # [thread](https://platform.openai.com/docs/api-reference/threads).
  332. #
  333. # @return [OpenAI::Models::Beta::Threads::Run]
  334. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  335. # @!attribute event
  336. #
  337. # @return [Symbol, :"thread.run.expired"]
  338. 1 required :event, const: :"thread.run.expired"
  339. # @!method initialize(data:, event: :"thread.run.expired")
  340. # Some parameter documentations has been truncated, see
  341. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired} for more details.
  342. #
  343. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  344. # expires.
  345. #
  346. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  347. #
  348. # @param event [Symbol, :"thread.run.expired"]
  349. end
  350. 1 class ThreadRunStepCreated < OpenAI::Internal::Type::BaseModel
  351. # @!attribute data
  352. # Represents a step in execution of a run.
  353. #
  354. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  355. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  356. # @!attribute event
  357. #
  358. # @return [Symbol, :"thread.run.step.created"]
  359. 1 required :event, const: :"thread.run.step.created"
  360. # @!method initialize(data:, event: :"thread.run.step.created")
  361. # Some parameter documentations has been truncated, see
  362. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated} for more
  363. # details.
  364. #
  365. # Occurs when a
  366. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  367. # is created.
  368. #
  369. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  370. #
  371. # @param event [Symbol, :"thread.run.step.created"]
  372. end
  373. 1 class ThreadRunStepInProgress < OpenAI::Internal::Type::BaseModel
  374. # @!attribute data
  375. # Represents a step in execution of a run.
  376. #
  377. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  378. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  379. # @!attribute event
  380. #
  381. # @return [Symbol, :"thread.run.step.in_progress"]
  382. 1 required :event, const: :"thread.run.step.in_progress"
  383. # @!method initialize(data:, event: :"thread.run.step.in_progress")
  384. # Some parameter documentations has been truncated, see
  385. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress} for more
  386. # details.
  387. #
  388. # Occurs when a
  389. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  390. # moves to an `in_progress` state.
  391. #
  392. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  393. #
  394. # @param event [Symbol, :"thread.run.step.in_progress"]
  395. end
  396. 1 class ThreadRunStepDelta < OpenAI::Internal::Type::BaseModel
  397. # @!attribute data
  398. # Represents a run step delta i.e. any changed fields on a run step during
  399. # streaming.
  400. #
  401. # @return [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent]
  402. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStepDeltaEvent }
  403. # @!attribute event
  404. #
  405. # @return [Symbol, :"thread.run.step.delta"]
  406. 1 required :event, const: :"thread.run.step.delta"
  407. # @!method initialize(data:, event: :"thread.run.step.delta")
  408. # Some parameter documentations has been truncated, see
  409. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta} for more
  410. # details.
  411. #
  412. # Occurs when parts of a
  413. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  414. # are being streamed.
  415. #
  416. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent] Represents a run step delta i.e. any changed fields on a run step during streami
  417. #
  418. # @param event [Symbol, :"thread.run.step.delta"]
  419. end
  420. 1 class ThreadRunStepCompleted < OpenAI::Internal::Type::BaseModel
  421. # @!attribute data
  422. # Represents a step in execution of a run.
  423. #
  424. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  425. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  426. # @!attribute event
  427. #
  428. # @return [Symbol, :"thread.run.step.completed"]
  429. 1 required :event, const: :"thread.run.step.completed"
  430. # @!method initialize(data:, event: :"thread.run.step.completed")
  431. # Some parameter documentations has been truncated, see
  432. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted} for more
  433. # details.
  434. #
  435. # Occurs when a
  436. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  437. # is completed.
  438. #
  439. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  440. #
  441. # @param event [Symbol, :"thread.run.step.completed"]
  442. end
  443. 1 class ThreadRunStepFailed < OpenAI::Internal::Type::BaseModel
  444. # @!attribute data
  445. # Represents a step in execution of a run.
  446. #
  447. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  448. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  449. # @!attribute event
  450. #
  451. # @return [Symbol, :"thread.run.step.failed"]
  452. 1 required :event, const: :"thread.run.step.failed"
  453. # @!method initialize(data:, event: :"thread.run.step.failed")
  454. # Some parameter documentations has been truncated, see
  455. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed} for more
  456. # details.
  457. #
  458. # Occurs when a
  459. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  460. # fails.
  461. #
  462. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  463. #
  464. # @param event [Symbol, :"thread.run.step.failed"]
  465. end
  466. 1 class ThreadRunStepCancelled < OpenAI::Internal::Type::BaseModel
  467. # @!attribute data
  468. # Represents a step in execution of a run.
  469. #
  470. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  471. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  472. # @!attribute event
  473. #
  474. # @return [Symbol, :"thread.run.step.cancelled"]
  475. 1 required :event, const: :"thread.run.step.cancelled"
  476. # @!method initialize(data:, event: :"thread.run.step.cancelled")
  477. # Some parameter documentations has been truncated, see
  478. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled} for more
  479. # details.
  480. #
  481. # Occurs when a
  482. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  483. # is cancelled.
  484. #
  485. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  486. #
  487. # @param event [Symbol, :"thread.run.step.cancelled"]
  488. end
  489. 1 class ThreadRunStepExpired < OpenAI::Internal::Type::BaseModel
  490. # @!attribute data
  491. # Represents a step in execution of a run.
  492. #
  493. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  494. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  495. # @!attribute event
  496. #
  497. # @return [Symbol, :"thread.run.step.expired"]
  498. 1 required :event, const: :"thread.run.step.expired"
  499. # @!method initialize(data:, event: :"thread.run.step.expired")
  500. # Some parameter documentations has been truncated, see
  501. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired} for more
  502. # details.
  503. #
  504. # Occurs when a
  505. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  506. # expires.
  507. #
  508. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  509. #
  510. # @param event [Symbol, :"thread.run.step.expired"]
  511. end
  512. 1 class ThreadMessageCreated < OpenAI::Internal::Type::BaseModel
  513. # @!attribute data
  514. # Represents a message within a
  515. # [thread](https://platform.openai.com/docs/api-reference/threads).
  516. #
  517. # @return [OpenAI::Models::Beta::Threads::Message]
  518. 1 required :data, -> { OpenAI::Beta::Threads::Message }
  519. # @!attribute event
  520. #
  521. # @return [Symbol, :"thread.message.created"]
  522. 1 required :event, const: :"thread.message.created"
  523. # @!method initialize(data:, event: :"thread.message.created")
  524. # Some parameter documentations has been truncated, see
  525. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated} for more
  526. # details.
  527. #
  528. # Occurs when a
  529. # [message](https://platform.openai.com/docs/api-reference/messages/object) is
  530. # created.
  531. #
  532. # @param data [OpenAI::Models::Beta::Threads::Message] Represents a message within a [thread](https://platform.openai.com/docs/api-refe
  533. #
  534. # @param event [Symbol, :"thread.message.created"]
  535. end
  536. 1 class ThreadMessageInProgress < OpenAI::Internal::Type::BaseModel
  537. # @!attribute data
  538. # Represents a message within a
  539. # [thread](https://platform.openai.com/docs/api-reference/threads).
  540. #
  541. # @return [OpenAI::Models::Beta::Threads::Message]
  542. 1 required :data, -> { OpenAI::Beta::Threads::Message }
  543. # @!attribute event
  544. #
  545. # @return [Symbol, :"thread.message.in_progress"]
  546. 1 required :event, const: :"thread.message.in_progress"
  547. # @!method initialize(data:, event: :"thread.message.in_progress")
  548. # Some parameter documentations has been truncated, see
  549. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress} for more
  550. # details.
  551. #
  552. # Occurs when a
  553. # [message](https://platform.openai.com/docs/api-reference/messages/object) moves
  554. # to an `in_progress` state.
  555. #
  556. # @param data [OpenAI::Models::Beta::Threads::Message] Represents a message within a [thread](https://platform.openai.com/docs/api-refe
  557. #
  558. # @param event [Symbol, :"thread.message.in_progress"]
  559. end
  560. 1 class ThreadMessageDelta < OpenAI::Internal::Type::BaseModel
  561. # @!attribute data
  562. # Represents a message delta i.e. any changed fields on a message during
  563. # streaming.
  564. #
  565. # @return [OpenAI::Models::Beta::Threads::MessageDeltaEvent]
  566. 1 required :data, -> { OpenAI::Beta::Threads::MessageDeltaEvent }
  567. # @!attribute event
  568. #
  569. # @return [Symbol, :"thread.message.delta"]
  570. 1 required :event, const: :"thread.message.delta"
  571. # @!method initialize(data:, event: :"thread.message.delta")
  572. # Some parameter documentations has been truncated, see
  573. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta} for more
  574. # details.
  575. #
  576. # Occurs when parts of a
  577. # [Message](https://platform.openai.com/docs/api-reference/messages/object) are
  578. # being streamed.
  579. #
  580. # @param data [OpenAI::Models::Beta::Threads::MessageDeltaEvent] Represents a message delta i.e. any changed fields on a message during streaming
  581. #
  582. # @param event [Symbol, :"thread.message.delta"]
  583. end
  584. 1 class ThreadMessageCompleted < OpenAI::Internal::Type::BaseModel
  585. # @!attribute data
  586. # Represents a message within a
  587. # [thread](https://platform.openai.com/docs/api-reference/threads).
  588. #
  589. # @return [OpenAI::Models::Beta::Threads::Message]
  590. 1 required :data, -> { OpenAI::Beta::Threads::Message }
  591. # @!attribute event
  592. #
  593. # @return [Symbol, :"thread.message.completed"]
  594. 1 required :event, const: :"thread.message.completed"
  595. # @!method initialize(data:, event: :"thread.message.completed")
  596. # Some parameter documentations has been truncated, see
  597. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted} for more
  598. # details.
  599. #
  600. # Occurs when a
  601. # [message](https://platform.openai.com/docs/api-reference/messages/object) is
  602. # completed.
  603. #
  604. # @param data [OpenAI::Models::Beta::Threads::Message] Represents a message within a [thread](https://platform.openai.com/docs/api-refe
  605. #
  606. # @param event [Symbol, :"thread.message.completed"]
  607. end
  608. 1 class ThreadMessageIncomplete < OpenAI::Internal::Type::BaseModel
  609. # @!attribute data
  610. # Represents a message within a
  611. # [thread](https://platform.openai.com/docs/api-reference/threads).
  612. #
  613. # @return [OpenAI::Models::Beta::Threads::Message]
  614. 1 required :data, -> { OpenAI::Beta::Threads::Message }
  615. # @!attribute event
  616. #
  617. # @return [Symbol, :"thread.message.incomplete"]
  618. 1 required :event, const: :"thread.message.incomplete"
  619. # @!method initialize(data:, event: :"thread.message.incomplete")
  620. # Some parameter documentations has been truncated, see
  621. # {OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete} for more
  622. # details.
  623. #
  624. # Occurs when a
  625. # [message](https://platform.openai.com/docs/api-reference/messages/object) ends
  626. # before it is completed.
  627. #
  628. # @param data [OpenAI::Models::Beta::Threads::Message] Represents a message within a [thread](https://platform.openai.com/docs/api-refe
  629. #
  630. # @param event [Symbol, :"thread.message.incomplete"]
  631. end
  632. 1 class ErrorEvent < OpenAI::Internal::Type::BaseModel
  633. # @!attribute data
  634. #
  635. # @return [OpenAI::Models::ErrorObject]
  636. 1 required :data, -> { OpenAI::ErrorObject }
  637. # @!attribute event
  638. #
  639. # @return [Symbol, :error]
  640. 1 required :event, const: :error
  641. # @!method initialize(data:, event: :error)
  642. # Occurs when an
  643. # [error](https://platform.openai.com/docs/guides/error-codes#api-errors) occurs.
  644. # This can happen due to an internal server error or a timeout.
  645. #
  646. # @param data [OpenAI::Models::ErrorObject]
  647. # @param event [Symbol, :error]
  648. end
  649. # @!method self.variants
  650. # @return [Array(OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent)]
  651. end
  652. end
  653. end
  654. end

openai-ruby/lib/openai/models/beta/assistant_tool.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module AssistantTool
  6. 1 extend OpenAI::Internal::Type::Union
  7. 1 discriminator :type
  8. 1 variant :code_interpreter, -> { OpenAI::Beta::CodeInterpreterTool }
  9. 1 variant :file_search, -> { OpenAI::Beta::FileSearchTool }
  10. 1 variant :function, -> { OpenAI::Beta::FunctionTool }
  11. # @!method self.variants
  12. # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool)]
  13. end
  14. end
  15. end
  16. end

openai-ruby/lib/openai/models/beta/assistant_tool_choice.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 class AssistantToolChoice < OpenAI::Internal::Type::BaseModel
  6. # @!attribute type
  7. # The type of the tool. If type is `function`, the function name must be set
  8. #
  9. # @return [Symbol, OpenAI::Models::Beta::AssistantToolChoice::Type]
  10. 1 required :type, enum: -> { OpenAI::Beta::AssistantToolChoice::Type }
  11. # @!attribute function
  12. #
  13. # @return [OpenAI::Models::Beta::AssistantToolChoiceFunction, nil]
  14. 1 optional :function, -> { OpenAI::Beta::AssistantToolChoiceFunction }
  15. # @!method initialize(type:, function: nil)
  16. # Specifies a tool the model should use. Use to force the model to call a specific
  17. # tool.
  18. #
  19. # @param type [Symbol, OpenAI::Models::Beta::AssistantToolChoice::Type] The type of the tool. If type is `function`, the function name must be set
  20. #
  21. # @param function [OpenAI::Models::Beta::AssistantToolChoiceFunction]
  22. # The type of the tool. If type is `function`, the function name must be set
  23. #
  24. # @see OpenAI::Models::Beta::AssistantToolChoice#type
  25. 1 module Type
  26. 1 extend OpenAI::Internal::Type::Enum
  27. 1 FUNCTION = :function
  28. 1 CODE_INTERPRETER = :code_interpreter
  29. 1 FILE_SEARCH = :file_search
  30. # @!method self.values
  31. # @return [Array<Symbol>]
  32. end
  33. end
  34. end
  35. end
  36. end

openai-ruby/lib/openai/models/beta/assistant_tool_choice_function.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 class AssistantToolChoiceFunction < OpenAI::Internal::Type::BaseModel
  6. # @!attribute name
  7. # The name of the function to call.
  8. #
  9. # @return [String]
  10. 1 required :name, String
  11. # @!method initialize(name:)
  12. # @param name [String] The name of the function to call.
  13. end
  14. end
  15. end
  16. end

openai-ruby/lib/openai/models/beta/assistant_tool_choice_option.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # Controls which (if any) tool is called by the model. `none` means the model will
  6. # not call any tools and instead generates a message. `auto` is the default value
  7. # and means the model can pick between generating a message or calling one or more
  8. # tools. `required` means the model must call one or more tools before responding
  9. # to the user. Specifying a particular tool like `{"type": "file_search"}` or
  10. # `{"type": "function", "function": {"name": "my_function"}}` forces the model to
  11. # call that tool.
  12. 1 module AssistantToolChoiceOption
  13. 1 extend OpenAI::Internal::Type::Union
  14. # `none` means the model will not call any tools and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools before responding to the user.
  15. 1 variant enum: -> { OpenAI::Beta::AssistantToolChoiceOption::Auto }
  16. # Specifies a tool the model should use. Use to force the model to call a specific tool.
  17. 1 variant -> { OpenAI::Beta::AssistantToolChoice }
  18. # `none` means the model will not call any tools and instead generates a message.
  19. # `auto` means the model can pick between generating a message or calling one or
  20. # more tools. `required` means the model must call one or more tools before
  21. # responding to the user.
  22. 1 module Auto
  23. 1 extend OpenAI::Internal::Type::Enum
  24. 1 NONE = :none
  25. 1 AUTO = :auto
  26. 1 REQUIRED = :required
  27. # @!method self.values
  28. # @return [Array<Symbol>]
  29. end
  30. # @!method self.variants
  31. # @return [Array(Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice)]
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/beta/assistant_update_params.rb

98.04% lines covered

100.0% branches covered

102 relevant lines. 100 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Assistants#update
  6. 1 class AssistantUpdateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute description
  10. # The description of the assistant. The maximum length is 512 characters.
  11. #
  12. # @return [String, nil]
  13. 1 optional :description, String, nil?: true
  14. # @!attribute instructions
  15. # The system instructions that the assistant uses. The maximum length is 256,000
  16. # characters.
  17. #
  18. # @return [String, nil]
  19. 1 optional :instructions, String, nil?: true
  20. # @!attribute metadata
  21. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  22. # for storing additional information about the object in a structured format, and
  23. # querying for objects via API or the dashboard.
  24. #
  25. # Keys are strings with a maximum length of 64 characters. Values are strings with
  26. # a maximum length of 512 characters.
  27. #
  28. # @return [Hash{Symbol=>String}, nil]
  29. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  30. # @!attribute model
  31. # ID of the model to use. You can use the
  32. # [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  33. # see all of your available models, or see our
  34. # [Model overview](https://platform.openai.com/docs/models) for descriptions of
  35. # them.
  36. #
  37. # @return [String, Symbol, OpenAI::Models::Beta::AssistantUpdateParams::Model, nil]
  38. 1 optional :model, union: -> { OpenAI::Beta::AssistantUpdateParams::Model }
  39. # @!attribute name
  40. # The name of the assistant. The maximum length is 256 characters.
  41. #
  42. # @return [String, nil]
  43. 1 optional :name, String, nil?: true
  44. # @!attribute reasoning_effort
  45. # **o-series models only**
  46. #
  47. # Constrains effort on reasoning for
  48. # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
  49. # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
  50. # result in faster responses and fewer tokens used on reasoning in a response.
  51. #
  52. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  53. 1 optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  54. # @!attribute response_format
  55. # Specifies the format that the model must output. Compatible with
  56. # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  57. # [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  58. # and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  59. #
  60. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  61. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  62. # in the
  63. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  64. #
  65. # Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  66. # message the model generates is valid JSON.
  67. #
  68. # **Important:** when using JSON mode, you **must** also instruct the model to
  69. # produce JSON yourself via a system or user message. Without this, the model may
  70. # generate an unending stream of whitespace until the generation reaches the token
  71. # limit, resulting in a long-running and seemingly "stuck" request. Also note that
  72. # the message content may be partially cut off if `finish_reason="length"`, which
  73. # indicates the generation exceeded `max_tokens` or the conversation exceeded the
  74. # max context length.
  75. #
  76. # @return [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil]
  77. 1 optional :response_format, union: -> { OpenAI::Beta::AssistantResponseFormatOption }, nil?: true
  78. # @!attribute temperature
  79. # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  80. # make the output more random, while lower values like 0.2 will make it more
  81. # focused and deterministic.
  82. #
  83. # @return [Float, nil]
  84. 1 optional :temperature, Float, nil?: true
  85. # @!attribute tool_resources
  86. # A set of resources that are used by the assistant's tools. The resources are
  87. # specific to the type of tool. For example, the `code_interpreter` tool requires
  88. # a list of file IDs, while the `file_search` tool requires a list of vector store
  89. # IDs.
  90. #
  91. # @return [OpenAI::Models::Beta::AssistantUpdateParams::ToolResources, nil]
  92. 1 optional :tool_resources, -> { OpenAI::Beta::AssistantUpdateParams::ToolResources }, nil?: true
  93. # @!attribute tools
  94. # A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  95. # assistant. Tools can be of types `code_interpreter`, `file_search`, or
  96. # `function`.
  97. #
  98. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil]
  99. 1 optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::AssistantTool] }
  100. # @!attribute top_p
  101. # An alternative to sampling with temperature, called nucleus sampling, where the
  102. # model considers the results of the tokens with top_p probability mass. So 0.1
  103. # means only the tokens comprising the top 10% probability mass are considered.
  104. #
  105. # We generally recommend altering this or temperature but not both.
  106. #
  107. # @return [Float, nil]
  108. 1 optional :top_p, Float, nil?: true
  109. # @!method initialize(description: nil, instructions: nil, metadata: nil, model: nil, name: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_resources: nil, tools: nil, top_p: nil, request_options: {})
  110. # Some parameter documentations has been truncated, see
  111. # {OpenAI::Models::Beta::AssistantUpdateParams} for more details.
  112. #
  113. # @param description [String, nil] The description of the assistant. The maximum length is 512 characters.
  114. #
  115. # @param instructions [String, nil] The system instructions that the assistant uses. The maximum length is 256,000 c
  116. #
  117. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  118. #
  119. # @param model [String, Symbol, OpenAI::Models::Beta::AssistantUpdateParams::Model] ID of the model to use. You can use the [List models](https://platform.openai.co
  120. #
  121. # @param name [String, nil] The name of the assistant. The maximum length is 256 characters.
  122. #
  123. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] **o-series models only**
  124. #
  125. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  126. #
  127. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  128. #
  129. # @param tool_resources [OpenAI::Models::Beta::AssistantUpdateParams::ToolResources, nil] A set of resources that are used by the assistant's tools. The resources are spe
  130. #
  131. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>] A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  132. #
  133. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  134. #
  135. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  136. # ID of the model to use. You can use the
  137. # [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  138. # see all of your available models, or see our
  139. # [Model overview](https://platform.openai.com/docs/models) for descriptions of
  140. # them.
  141. 1 module Model
  142. 1 extend OpenAI::Internal::Type::Union
  143. 1 variant String
  144. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_1 }
  145. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_1_MINI }
  146. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_1_NANO }
  147. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_1_2025_04_14 }
  148. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_1_MINI_2025_04_14 }
  149. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_1_NANO_2025_04_14 }
  150. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::O3_MINI }
  151. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::O3_MINI_2025_01_31 }
  152. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::O1 }
  153. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::O1_2024_12_17 }
  154. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O }
  155. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_2024_11_20 }
  156. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_2024_08_06 }
  157. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_2024_05_13 }
  158. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_MINI }
  159. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4O_MINI_2024_07_18 }
  160. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_5_PREVIEW }
  161. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_5_PREVIEW_2025_02_27 }
  162. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_TURBO }
  163. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_TURBO_2024_04_09 }
  164. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_0125_PREVIEW }
  165. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_TURBO_PREVIEW }
  166. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_1106_PREVIEW }
  167. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_VISION_PREVIEW }
  168. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4 }
  169. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_0314 }
  170. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_0613 }
  171. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_32K }
  172. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_32K_0314 }
  173. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_4_32K_0613 }
  174. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO }
  175. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_16K }
  176. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_0613 }
  177. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_1106 }
  178. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_0125 }
  179. 1 variant const: -> { OpenAI::Models::Beta::AssistantUpdateParams::Model::GPT_3_5_TURBO_16K_0613 }
  180. # @!method self.variants
  181. # @return [Array(String, Symbol)]
  182. 1 define_sorbet_constant!(:Variants) do
  183. T.type_alias { T.any(String, OpenAI::Beta::AssistantUpdateParams::Model::TaggedSymbol) }
  184. end
  185. # @!group
  186. 1 GPT_4_1 = :"gpt-4.1"
  187. 1 GPT_4_1_MINI = :"gpt-4.1-mini"
  188. 1 GPT_4_1_NANO = :"gpt-4.1-nano"
  189. 1 GPT_4_1_2025_04_14 = :"gpt-4.1-2025-04-14"
  190. 1 GPT_4_1_MINI_2025_04_14 = :"gpt-4.1-mini-2025-04-14"
  191. 1 GPT_4_1_NANO_2025_04_14 = :"gpt-4.1-nano-2025-04-14"
  192. 1 O3_MINI = :"o3-mini"
  193. 1 O3_MINI_2025_01_31 = :"o3-mini-2025-01-31"
  194. 1 O1 = :o1
  195. 1 O1_2024_12_17 = :"o1-2024-12-17"
  196. 1 GPT_4O = :"gpt-4o"
  197. 1 GPT_4O_2024_11_20 = :"gpt-4o-2024-11-20"
  198. 1 GPT_4O_2024_08_06 = :"gpt-4o-2024-08-06"
  199. 1 GPT_4O_2024_05_13 = :"gpt-4o-2024-05-13"
  200. 1 GPT_4O_MINI = :"gpt-4o-mini"
  201. 1 GPT_4O_MINI_2024_07_18 = :"gpt-4o-mini-2024-07-18"
  202. 1 GPT_4_5_PREVIEW = :"gpt-4.5-preview"
  203. 1 GPT_4_5_PREVIEW_2025_02_27 = :"gpt-4.5-preview-2025-02-27"
  204. 1 GPT_4_TURBO = :"gpt-4-turbo"
  205. 1 GPT_4_TURBO_2024_04_09 = :"gpt-4-turbo-2024-04-09"
  206. 1 GPT_4_0125_PREVIEW = :"gpt-4-0125-preview"
  207. 1 GPT_4_TURBO_PREVIEW = :"gpt-4-turbo-preview"
  208. 1 GPT_4_1106_PREVIEW = :"gpt-4-1106-preview"
  209. 1 GPT_4_VISION_PREVIEW = :"gpt-4-vision-preview"
  210. 1 GPT_4 = :"gpt-4"
  211. 1 GPT_4_0314 = :"gpt-4-0314"
  212. 1 GPT_4_0613 = :"gpt-4-0613"
  213. 1 GPT_4_32K = :"gpt-4-32k"
  214. 1 GPT_4_32K_0314 = :"gpt-4-32k-0314"
  215. 1 GPT_4_32K_0613 = :"gpt-4-32k-0613"
  216. 1 GPT_3_5_TURBO = :"gpt-3.5-turbo"
  217. 1 GPT_3_5_TURBO_16K = :"gpt-3.5-turbo-16k"
  218. 1 GPT_3_5_TURBO_0613 = :"gpt-3.5-turbo-0613"
  219. 1 GPT_3_5_TURBO_1106 = :"gpt-3.5-turbo-1106"
  220. 1 GPT_3_5_TURBO_0125 = :"gpt-3.5-turbo-0125"
  221. 1 GPT_3_5_TURBO_16K_0613 = :"gpt-3.5-turbo-16k-0613"
  222. # @!endgroup
  223. end
  224. 1 class ToolResources < OpenAI::Internal::Type::BaseModel
  225. # @!attribute code_interpreter
  226. #
  227. # @return [OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter, nil]
  228. 1 optional :code_interpreter,
  229. -> {
  230. OpenAI::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter
  231. }
  232. # @!attribute file_search
  233. #
  234. # @return [OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch, nil]
  235. 1 optional :file_search, -> { OpenAI::Beta::AssistantUpdateParams::ToolResources::FileSearch }
  236. # @!method initialize(code_interpreter: nil, file_search: nil)
  237. # A set of resources that are used by the assistant's tools. The resources are
  238. # specific to the type of tool. For example, the `code_interpreter` tool requires
  239. # a list of file IDs, while the `file_search` tool requires a list of vector store
  240. # IDs.
  241. #
  242. # @param code_interpreter [OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter]
  243. # @param file_search [OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch]
  244. # @see OpenAI::Models::Beta::AssistantUpdateParams::ToolResources#code_interpreter
  245. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  246. # @!attribute file_ids
  247. # Overrides the list of
  248. # [file](https://platform.openai.com/docs/api-reference/files) IDs made available
  249. # to the `code_interpreter` tool. There can be a maximum of 20 files associated
  250. # with the tool.
  251. #
  252. # @return [Array<String>, nil]
  253. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  254. # @!method initialize(file_ids: nil)
  255. # Some parameter documentations has been truncated, see
  256. # {OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::CodeInterpreter}
  257. # for more details.
  258. #
  259. # @param file_ids [Array<String>] Overrides the list of [file](https://platform.openai.com/docs/api-reference/file
  260. end
  261. # @see OpenAI::Models::Beta::AssistantUpdateParams::ToolResources#file_search
  262. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  263. # @!attribute vector_store_ids
  264. # Overrides the
  265. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  266. # attached to this assistant. There can be a maximum of 1 vector store attached to
  267. # the assistant.
  268. #
  269. # @return [Array<String>, nil]
  270. 1 optional :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]
  271. # @!method initialize(vector_store_ids: nil)
  272. # Some parameter documentations has been truncated, see
  273. # {OpenAI::Models::Beta::AssistantUpdateParams::ToolResources::FileSearch} for
  274. # more details.
  275. #
  276. # @param vector_store_ids [Array<String>] Overrides the [vector store](https://platform.openai.com/docs/api-reference/vect
  277. end
  278. end
  279. end
  280. end
  281. end
  282. end

openai-ruby/lib/openai/models/beta/code_interpreter_tool.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 class CodeInterpreterTool < OpenAI::Internal::Type::BaseModel
  6. # @!attribute type
  7. # The type of tool being defined: `code_interpreter`
  8. #
  9. # @return [Symbol, :code_interpreter]
  10. 1 required :type, const: :code_interpreter
  11. # @!method initialize(type: :code_interpreter)
  12. # @param type [Symbol, :code_interpreter] The type of tool being defined: `code_interpreter`
  13. end
  14. end
  15. end
  16. end

openai-ruby/lib/openai/models/beta/file_search_tool.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 class FileSearchTool < OpenAI::Internal::Type::BaseModel
  6. # @!attribute type
  7. # The type of tool being defined: `file_search`
  8. #
  9. # @return [Symbol, :file_search]
  10. 1 required :type, const: :file_search
  11. # @!attribute file_search
  12. # Overrides for the file search tool.
  13. #
  14. # @return [OpenAI::Models::Beta::FileSearchTool::FileSearch, nil]
  15. 1 optional :file_search, -> { OpenAI::Beta::FileSearchTool::FileSearch }
  16. # @!method initialize(file_search: nil, type: :file_search)
  17. # @param file_search [OpenAI::Models::Beta::FileSearchTool::FileSearch] Overrides for the file search tool.
  18. #
  19. # @param type [Symbol, :file_search] The type of tool being defined: `file_search`
  20. # @see OpenAI::Models::Beta::FileSearchTool#file_search
  21. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  22. # @!attribute max_num_results
  23. # The maximum number of results the file search tool should output. The default is
  24. # 20 for `gpt-4*` models and 5 for `gpt-3.5-turbo`. This number should be between
  25. # 1 and 50 inclusive.
  26. #
  27. # Note that the file search tool may output fewer than `max_num_results` results.
  28. # See the
  29. # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
  30. # for more information.
  31. #
  32. # @return [Integer, nil]
  33. 1 optional :max_num_results, Integer
  34. # @!attribute ranking_options
  35. # The ranking options for the file search. If not specified, the file search tool
  36. # will use the `auto` ranker and a score_threshold of 0.
  37. #
  38. # See the
  39. # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
  40. # for more information.
  41. #
  42. # @return [OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions, nil]
  43. 1 optional :ranking_options, -> { OpenAI::Beta::FileSearchTool::FileSearch::RankingOptions }
  44. # @!method initialize(max_num_results: nil, ranking_options: nil)
  45. # Some parameter documentations has been truncated, see
  46. # {OpenAI::Models::Beta::FileSearchTool::FileSearch} for more details.
  47. #
  48. # Overrides for the file search tool.
  49. #
  50. # @param max_num_results [Integer] The maximum number of results the file search tool should output. The default is
  51. #
  52. # @param ranking_options [OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions] The ranking options for the file search. If not specified, the file search tool
  53. # @see OpenAI::Models::Beta::FileSearchTool::FileSearch#ranking_options
  54. 1 class RankingOptions < OpenAI::Internal::Type::BaseModel
  55. # @!attribute score_threshold
  56. # The score threshold for the file search. All values must be a floating point
  57. # number between 0 and 1.
  58. #
  59. # @return [Float]
  60. 1 required :score_threshold, Float
  61. # @!attribute ranker
  62. # The ranker to use for the file search. If not specified will use the `auto`
  63. # ranker.
  64. #
  65. # @return [Symbol, OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker, nil]
  66. 1 optional :ranker, enum: -> { OpenAI::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker }
  67. # @!method initialize(score_threshold:, ranker: nil)
  68. # Some parameter documentations has been truncated, see
  69. # {OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions} for more
  70. # details.
  71. #
  72. # The ranking options for the file search. If not specified, the file search tool
  73. # will use the `auto` ranker and a score_threshold of 0.
  74. #
  75. # See the
  76. # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
  77. # for more information.
  78. #
  79. # @param score_threshold [Float] The score threshold for the file search. All values must be a floating point num
  80. #
  81. # @param ranker [Symbol, OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions::Ranker] The ranker to use for the file search. If not specified will use the `auto` rank
  82. # The ranker to use for the file search. If not specified will use the `auto`
  83. # ranker.
  84. #
  85. # @see OpenAI::Models::Beta::FileSearchTool::FileSearch::RankingOptions#ranker
  86. 1 module Ranker
  87. 1 extend OpenAI::Internal::Type::Enum
  88. 1 AUTO = :auto
  89. 1 DEFAULT_2024_08_21 = :default_2024_08_21
  90. # @!method self.values
  91. # @return [Array<Symbol>]
  92. end
  93. end
  94. end
  95. end
  96. end
  97. end
  98. end

openai-ruby/lib/openai/models/beta/function_tool.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 class FunctionTool < OpenAI::Internal::Type::BaseModel
  6. # @!attribute function
  7. #
  8. # @return [OpenAI::Models::FunctionDefinition]
  9. 1 required :function, -> { OpenAI::FunctionDefinition }
  10. # @!attribute type
  11. # The type of tool being defined: `function`
  12. #
  13. # @return [Symbol, :function]
  14. 1 required :type, const: :function
  15. # @!method initialize(function:, type: :function)
  16. # @param function [OpenAI::Models::FunctionDefinition]
  17. #
  18. # @param type [Symbol, :function] The type of tool being defined: `function`
  19. end
  20. end
  21. end
  22. end

openai-ruby/lib/openai/models/beta/message_stream_event.rb

96.3% lines covered

100.0% branches covered

27 relevant lines. 26 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # Occurs when a
  6. # [message](https://platform.openai.com/docs/api-reference/messages/object) is
  7. # created.
  8. 1 module MessageStreamEvent
  9. 1 extend OpenAI::Internal::Type::Union
  10. 1 discriminator :event
  11. # Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is created.
  12. 1 variant :"thread.message.created", -> { OpenAI::Beta::MessageStreamEvent::ThreadMessageCreated }
  13. # Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) moves to an `in_progress` state.
  14. 1 variant :"thread.message.in_progress",
  15. -> {
  16. OpenAI::Beta::MessageStreamEvent::ThreadMessageInProgress
  17. }
  18. # Occurs when parts of a [Message](https://platform.openai.com/docs/api-reference/messages/object) are being streamed.
  19. 1 variant :"thread.message.delta", -> { OpenAI::Beta::MessageStreamEvent::ThreadMessageDelta }
  20. # Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) is completed.
  21. 1 variant :"thread.message.completed", -> { OpenAI::Beta::MessageStreamEvent::ThreadMessageCompleted }
  22. # Occurs when a [message](https://platform.openai.com/docs/api-reference/messages/object) ends before it is completed.
  23. 1 variant :"thread.message.incomplete", -> { OpenAI::Beta::MessageStreamEvent::ThreadMessageIncomplete }
  24. 1 class ThreadMessageCreated < OpenAI::Internal::Type::BaseModel
  25. # @!attribute data
  26. # Represents a message within a
  27. # [thread](https://platform.openai.com/docs/api-reference/threads).
  28. #
  29. # @return [OpenAI::Models::Beta::Threads::Message]
  30. 1 required :data, -> { OpenAI::Beta::Threads::Message }
  31. # @!attribute event
  32. #
  33. # @return [Symbol, :"thread.message.created"]
  34. 1 required :event, const: :"thread.message.created"
  35. # @!method initialize(data:, event: :"thread.message.created")
  36. # Some parameter documentations has been truncated, see
  37. # {OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCreated} for more
  38. # details.
  39. #
  40. # Occurs when a
  41. # [message](https://platform.openai.com/docs/api-reference/messages/object) is
  42. # created.
  43. #
  44. # @param data [OpenAI::Models::Beta::Threads::Message] Represents a message within a [thread](https://platform.openai.com/docs/api-refe
  45. #
  46. # @param event [Symbol, :"thread.message.created"]
  47. end
  48. 1 class ThreadMessageInProgress < OpenAI::Internal::Type::BaseModel
  49. # @!attribute data
  50. # Represents a message within a
  51. # [thread](https://platform.openai.com/docs/api-reference/threads).
  52. #
  53. # @return [OpenAI::Models::Beta::Threads::Message]
  54. 1 required :data, -> { OpenAI::Beta::Threads::Message }
  55. # @!attribute event
  56. #
  57. # @return [Symbol, :"thread.message.in_progress"]
  58. 1 required :event, const: :"thread.message.in_progress"
  59. # @!method initialize(data:, event: :"thread.message.in_progress")
  60. # Some parameter documentations has been truncated, see
  61. # {OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageInProgress} for more
  62. # details.
  63. #
  64. # Occurs when a
  65. # [message](https://platform.openai.com/docs/api-reference/messages/object) moves
  66. # to an `in_progress` state.
  67. #
  68. # @param data [OpenAI::Models::Beta::Threads::Message] Represents a message within a [thread](https://platform.openai.com/docs/api-refe
  69. #
  70. # @param event [Symbol, :"thread.message.in_progress"]
  71. end
  72. 1 class ThreadMessageDelta < OpenAI::Internal::Type::BaseModel
  73. # @!attribute data
  74. # Represents a message delta i.e. any changed fields on a message during
  75. # streaming.
  76. #
  77. # @return [OpenAI::Models::Beta::Threads::MessageDeltaEvent]
  78. 1 required :data, -> { OpenAI::Beta::Threads::MessageDeltaEvent }
  79. # @!attribute event
  80. #
  81. # @return [Symbol, :"thread.message.delta"]
  82. 1 required :event, const: :"thread.message.delta"
  83. # @!method initialize(data:, event: :"thread.message.delta")
  84. # Some parameter documentations has been truncated, see
  85. # {OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageDelta} for more details.
  86. #
  87. # Occurs when parts of a
  88. # [Message](https://platform.openai.com/docs/api-reference/messages/object) are
  89. # being streamed.
  90. #
  91. # @param data [OpenAI::Models::Beta::Threads::MessageDeltaEvent] Represents a message delta i.e. any changed fields on a message during streaming
  92. #
  93. # @param event [Symbol, :"thread.message.delta"]
  94. end
  95. 1 class ThreadMessageCompleted < OpenAI::Internal::Type::BaseModel
  96. # @!attribute data
  97. # Represents a message within a
  98. # [thread](https://platform.openai.com/docs/api-reference/threads).
  99. #
  100. # @return [OpenAI::Models::Beta::Threads::Message]
  101. 1 required :data, -> { OpenAI::Beta::Threads::Message }
  102. # @!attribute event
  103. #
  104. # @return [Symbol, :"thread.message.completed"]
  105. 1 required :event, const: :"thread.message.completed"
  106. # @!method initialize(data:, event: :"thread.message.completed")
  107. # Some parameter documentations has been truncated, see
  108. # {OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCompleted} for more
  109. # details.
  110. #
  111. # Occurs when a
  112. # [message](https://platform.openai.com/docs/api-reference/messages/object) is
  113. # completed.
  114. #
  115. # @param data [OpenAI::Models::Beta::Threads::Message] Represents a message within a [thread](https://platform.openai.com/docs/api-refe
  116. #
  117. # @param event [Symbol, :"thread.message.completed"]
  118. end
  119. 1 class ThreadMessageIncomplete < OpenAI::Internal::Type::BaseModel
  120. # @!attribute data
  121. # Represents a message within a
  122. # [thread](https://platform.openai.com/docs/api-reference/threads).
  123. #
  124. # @return [OpenAI::Models::Beta::Threads::Message]
  125. 1 required :data, -> { OpenAI::Beta::Threads::Message }
  126. # @!attribute event
  127. #
  128. # @return [Symbol, :"thread.message.incomplete"]
  129. 1 required :event, const: :"thread.message.incomplete"
  130. # @!method initialize(data:, event: :"thread.message.incomplete")
  131. # Some parameter documentations has been truncated, see
  132. # {OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageIncomplete} for more
  133. # details.
  134. #
  135. # Occurs when a
  136. # [message](https://platform.openai.com/docs/api-reference/messages/object) ends
  137. # before it is completed.
  138. #
  139. # @param data [OpenAI::Models::Beta::Threads::Message] Represents a message within a [thread](https://platform.openai.com/docs/api-refe
  140. #
  141. # @param event [Symbol, :"thread.message.incomplete"]
  142. end
  143. # @!method self.variants
  144. # @return [Array(OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::MessageStreamEvent::ThreadMessageIncomplete)]
  145. end
  146. end
  147. end
  148. end

openai-ruby/lib/openai/models/beta/run_step_stream_event.rb

97.14% lines covered

100.0% branches covered

35 relevant lines. 34 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # Occurs when a
  6. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  7. # is created.
  8. 1 module RunStepStreamEvent
  9. 1 extend OpenAI::Internal::Type::Union
  10. 1 discriminator :event
  11. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is created.
  12. 1 variant :"thread.run.step.created", -> { OpenAI::Beta::RunStepStreamEvent::ThreadRunStepCreated }
  13. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) moves to an `in_progress` state.
  14. 1 variant :"thread.run.step.in_progress",
  15. -> {
  16. OpenAI::Beta::RunStepStreamEvent::ThreadRunStepInProgress
  17. }
  18. # Occurs when parts of a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) are being streamed.
  19. 1 variant :"thread.run.step.delta", -> { OpenAI::Beta::RunStepStreamEvent::ThreadRunStepDelta }
  20. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is completed.
  21. 1 variant :"thread.run.step.completed", -> { OpenAI::Beta::RunStepStreamEvent::ThreadRunStepCompleted }
  22. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) fails.
  23. 1 variant :"thread.run.step.failed", -> { OpenAI::Beta::RunStepStreamEvent::ThreadRunStepFailed }
  24. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) is cancelled.
  25. 1 variant :"thread.run.step.cancelled", -> { OpenAI::Beta::RunStepStreamEvent::ThreadRunStepCancelled }
  26. # Occurs when a [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object) expires.
  27. 1 variant :"thread.run.step.expired", -> { OpenAI::Beta::RunStepStreamEvent::ThreadRunStepExpired }
  28. 1 class ThreadRunStepCreated < OpenAI::Internal::Type::BaseModel
  29. # @!attribute data
  30. # Represents a step in execution of a run.
  31. #
  32. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  33. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  34. # @!attribute event
  35. #
  36. # @return [Symbol, :"thread.run.step.created"]
  37. 1 required :event, const: :"thread.run.step.created"
  38. # @!method initialize(data:, event: :"thread.run.step.created")
  39. # Some parameter documentations has been truncated, see
  40. # {OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCreated} for more
  41. # details.
  42. #
  43. # Occurs when a
  44. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  45. # is created.
  46. #
  47. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  48. #
  49. # @param event [Symbol, :"thread.run.step.created"]
  50. end
  51. 1 class ThreadRunStepInProgress < OpenAI::Internal::Type::BaseModel
  52. # @!attribute data
  53. # Represents a step in execution of a run.
  54. #
  55. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  56. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  57. # @!attribute event
  58. #
  59. # @return [Symbol, :"thread.run.step.in_progress"]
  60. 1 required :event, const: :"thread.run.step.in_progress"
  61. # @!method initialize(data:, event: :"thread.run.step.in_progress")
  62. # Some parameter documentations has been truncated, see
  63. # {OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepInProgress} for more
  64. # details.
  65. #
  66. # Occurs when a
  67. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  68. # moves to an `in_progress` state.
  69. #
  70. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  71. #
  72. # @param event [Symbol, :"thread.run.step.in_progress"]
  73. end
  74. 1 class ThreadRunStepDelta < OpenAI::Internal::Type::BaseModel
  75. # @!attribute data
  76. # Represents a run step delta i.e. any changed fields on a run step during
  77. # streaming.
  78. #
  79. # @return [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent]
  80. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStepDeltaEvent }
  81. # @!attribute event
  82. #
  83. # @return [Symbol, :"thread.run.step.delta"]
  84. 1 required :event, const: :"thread.run.step.delta"
  85. # @!method initialize(data:, event: :"thread.run.step.delta")
  86. # Some parameter documentations has been truncated, see
  87. # {OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepDelta} for more details.
  88. #
  89. # Occurs when parts of a
  90. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  91. # are being streamed.
  92. #
  93. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaEvent] Represents a run step delta i.e. any changed fields on a run step during streami
  94. #
  95. # @param event [Symbol, :"thread.run.step.delta"]
  96. end
  97. 1 class ThreadRunStepCompleted < OpenAI::Internal::Type::BaseModel
  98. # @!attribute data
  99. # Represents a step in execution of a run.
  100. #
  101. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  102. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  103. # @!attribute event
  104. #
  105. # @return [Symbol, :"thread.run.step.completed"]
  106. 1 required :event, const: :"thread.run.step.completed"
  107. # @!method initialize(data:, event: :"thread.run.step.completed")
  108. # Some parameter documentations has been truncated, see
  109. # {OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCompleted} for more
  110. # details.
  111. #
  112. # Occurs when a
  113. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  114. # is completed.
  115. #
  116. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  117. #
  118. # @param event [Symbol, :"thread.run.step.completed"]
  119. end
  120. 1 class ThreadRunStepFailed < OpenAI::Internal::Type::BaseModel
  121. # @!attribute data
  122. # Represents a step in execution of a run.
  123. #
  124. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  125. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  126. # @!attribute event
  127. #
  128. # @return [Symbol, :"thread.run.step.failed"]
  129. 1 required :event, const: :"thread.run.step.failed"
  130. # @!method initialize(data:, event: :"thread.run.step.failed")
  131. # Some parameter documentations has been truncated, see
  132. # {OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepFailed} for more
  133. # details.
  134. #
  135. # Occurs when a
  136. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  137. # fails.
  138. #
  139. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  140. #
  141. # @param event [Symbol, :"thread.run.step.failed"]
  142. end
  143. 1 class ThreadRunStepCancelled < OpenAI::Internal::Type::BaseModel
  144. # @!attribute data
  145. # Represents a step in execution of a run.
  146. #
  147. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  148. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  149. # @!attribute event
  150. #
  151. # @return [Symbol, :"thread.run.step.cancelled"]
  152. 1 required :event, const: :"thread.run.step.cancelled"
  153. # @!method initialize(data:, event: :"thread.run.step.cancelled")
  154. # Some parameter documentations has been truncated, see
  155. # {OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCancelled} for more
  156. # details.
  157. #
  158. # Occurs when a
  159. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  160. # is cancelled.
  161. #
  162. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  163. #
  164. # @param event [Symbol, :"thread.run.step.cancelled"]
  165. end
  166. 1 class ThreadRunStepExpired < OpenAI::Internal::Type::BaseModel
  167. # @!attribute data
  168. # Represents a step in execution of a run.
  169. #
  170. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  171. 1 required :data, -> { OpenAI::Beta::Threads::Runs::RunStep }
  172. # @!attribute event
  173. #
  174. # @return [Symbol, :"thread.run.step.expired"]
  175. 1 required :event, const: :"thread.run.step.expired"
  176. # @!method initialize(data:, event: :"thread.run.step.expired")
  177. # Some parameter documentations has been truncated, see
  178. # {OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepExpired} for more
  179. # details.
  180. #
  181. # Occurs when a
  182. # [run step](https://platform.openai.com/docs/api-reference/run-steps/step-object)
  183. # expires.
  184. #
  185. # @param data [OpenAI::Models::Beta::Threads::Runs::RunStep] Represents a step in execution of a run.
  186. #
  187. # @param event [Symbol, :"thread.run.step.expired"]
  188. end
  189. # @!method self.variants
  190. # @return [Array(OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::RunStepStreamEvent::ThreadRunStepExpired)]
  191. end
  192. end
  193. end
  194. end

openai-ruby/lib/openai/models/beta/run_stream_event.rb

100.0% lines covered

100.0% branches covered

46 relevant lines. 46 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # Occurs when a new
  6. # [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
  7. 1 module RunStreamEvent
  8. 1 extend OpenAI::Internal::Type::Union
  9. 1 discriminator :event
  10. # Occurs when a new [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
  11. 1 variant :"thread.run.created", -> { OpenAI::Beta::RunStreamEvent::ThreadRunCreated }
  12. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `queued` status.
  13. 1 variant :"thread.run.queued", -> { OpenAI::Beta::RunStreamEvent::ThreadRunQueued }
  14. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to an `in_progress` status.
  15. 1 variant :"thread.run.in_progress", -> { OpenAI::Beta::RunStreamEvent::ThreadRunInProgress }
  16. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `requires_action` status.
  17. 1 variant :"thread.run.requires_action", -> { OpenAI::Beta::RunStreamEvent::ThreadRunRequiresAction }
  18. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is completed.
  19. 1 variant :"thread.run.completed", -> { OpenAI::Beta::RunStreamEvent::ThreadRunCompleted }
  20. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) ends with status `incomplete`.
  21. 1 variant :"thread.run.incomplete", -> { OpenAI::Beta::RunStreamEvent::ThreadRunIncomplete }
  22. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) fails.
  23. 1 variant :"thread.run.failed", -> { OpenAI::Beta::RunStreamEvent::ThreadRunFailed }
  24. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) moves to a `cancelling` status.
  25. 1 variant :"thread.run.cancelling", -> { OpenAI::Beta::RunStreamEvent::ThreadRunCancelling }
  26. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) is cancelled.
  27. 1 variant :"thread.run.cancelled", -> { OpenAI::Beta::RunStreamEvent::ThreadRunCancelled }
  28. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object) expires.
  29. 1 variant :"thread.run.expired", -> { OpenAI::Beta::RunStreamEvent::ThreadRunExpired }
  30. 1 class ThreadRunCreated < OpenAI::Internal::Type::BaseModel
  31. # @!attribute data
  32. # Represents an execution run on a
  33. # [thread](https://platform.openai.com/docs/api-reference/threads).
  34. #
  35. # @return [OpenAI::Models::Beta::Threads::Run]
  36. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  37. # @!attribute event
  38. #
  39. # @return [Symbol, :"thread.run.created"]
  40. 1 required :event, const: :"thread.run.created"
  41. # @!method initialize(data:, event: :"thread.run.created")
  42. # Some parameter documentations has been truncated, see
  43. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunCreated} for more details.
  44. #
  45. # Occurs when a new
  46. # [run](https://platform.openai.com/docs/api-reference/runs/object) is created.
  47. #
  48. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  49. #
  50. # @param event [Symbol, :"thread.run.created"]
  51. end
  52. 1 class ThreadRunQueued < OpenAI::Internal::Type::BaseModel
  53. # @!attribute data
  54. # Represents an execution run on a
  55. # [thread](https://platform.openai.com/docs/api-reference/threads).
  56. #
  57. # @return [OpenAI::Models::Beta::Threads::Run]
  58. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  59. # @!attribute event
  60. #
  61. # @return [Symbol, :"thread.run.queued"]
  62. 1 required :event, const: :"thread.run.queued"
  63. # @!method initialize(data:, event: :"thread.run.queued")
  64. # Some parameter documentations has been truncated, see
  65. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunQueued} for more details.
  66. #
  67. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  68. # moves to a `queued` status.
  69. #
  70. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  71. #
  72. # @param event [Symbol, :"thread.run.queued"]
  73. end
  74. 1 class ThreadRunInProgress < OpenAI::Internal::Type::BaseModel
  75. # @!attribute data
  76. # Represents an execution run on a
  77. # [thread](https://platform.openai.com/docs/api-reference/threads).
  78. #
  79. # @return [OpenAI::Models::Beta::Threads::Run]
  80. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  81. # @!attribute event
  82. #
  83. # @return [Symbol, :"thread.run.in_progress"]
  84. 1 required :event, const: :"thread.run.in_progress"
  85. # @!method initialize(data:, event: :"thread.run.in_progress")
  86. # Some parameter documentations has been truncated, see
  87. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunInProgress} for more details.
  88. #
  89. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  90. # moves to an `in_progress` status.
  91. #
  92. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  93. #
  94. # @param event [Symbol, :"thread.run.in_progress"]
  95. end
  96. 1 class ThreadRunRequiresAction < OpenAI::Internal::Type::BaseModel
  97. # @!attribute data
  98. # Represents an execution run on a
  99. # [thread](https://platform.openai.com/docs/api-reference/threads).
  100. #
  101. # @return [OpenAI::Models::Beta::Threads::Run]
  102. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  103. # @!attribute event
  104. #
  105. # @return [Symbol, :"thread.run.requires_action"]
  106. 1 required :event, const: :"thread.run.requires_action"
  107. # @!method initialize(data:, event: :"thread.run.requires_action")
  108. # Some parameter documentations has been truncated, see
  109. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunRequiresAction} for more
  110. # details.
  111. #
  112. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  113. # moves to a `requires_action` status.
  114. #
  115. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  116. #
  117. # @param event [Symbol, :"thread.run.requires_action"]
  118. end
  119. 1 class ThreadRunCompleted < OpenAI::Internal::Type::BaseModel
  120. # @!attribute data
  121. # Represents an execution run on a
  122. # [thread](https://platform.openai.com/docs/api-reference/threads).
  123. #
  124. # @return [OpenAI::Models::Beta::Threads::Run]
  125. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  126. # @!attribute event
  127. #
  128. # @return [Symbol, :"thread.run.completed"]
  129. 1 required :event, const: :"thread.run.completed"
  130. # @!method initialize(data:, event: :"thread.run.completed")
  131. # Some parameter documentations has been truncated, see
  132. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunCompleted} for more details.
  133. #
  134. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  135. # is completed.
  136. #
  137. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  138. #
  139. # @param event [Symbol, :"thread.run.completed"]
  140. end
  141. 1 class ThreadRunIncomplete < OpenAI::Internal::Type::BaseModel
  142. # @!attribute data
  143. # Represents an execution run on a
  144. # [thread](https://platform.openai.com/docs/api-reference/threads).
  145. #
  146. # @return [OpenAI::Models::Beta::Threads::Run]
  147. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  148. # @!attribute event
  149. #
  150. # @return [Symbol, :"thread.run.incomplete"]
  151. 1 required :event, const: :"thread.run.incomplete"
  152. # @!method initialize(data:, event: :"thread.run.incomplete")
  153. # Some parameter documentations has been truncated, see
  154. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunIncomplete} for more details.
  155. #
  156. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  157. # ends with status `incomplete`.
  158. #
  159. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  160. #
  161. # @param event [Symbol, :"thread.run.incomplete"]
  162. end
  163. 1 class ThreadRunFailed < OpenAI::Internal::Type::BaseModel
  164. # @!attribute data
  165. # Represents an execution run on a
  166. # [thread](https://platform.openai.com/docs/api-reference/threads).
  167. #
  168. # @return [OpenAI::Models::Beta::Threads::Run]
  169. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  170. # @!attribute event
  171. #
  172. # @return [Symbol, :"thread.run.failed"]
  173. 1 required :event, const: :"thread.run.failed"
  174. # @!method initialize(data:, event: :"thread.run.failed")
  175. # Some parameter documentations has been truncated, see
  176. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunFailed} for more details.
  177. #
  178. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  179. # fails.
  180. #
  181. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  182. #
  183. # @param event [Symbol, :"thread.run.failed"]
  184. end
  185. 1 class ThreadRunCancelling < OpenAI::Internal::Type::BaseModel
  186. # @!attribute data
  187. # Represents an execution run on a
  188. # [thread](https://platform.openai.com/docs/api-reference/threads).
  189. #
  190. # @return [OpenAI::Models::Beta::Threads::Run]
  191. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  192. # @!attribute event
  193. #
  194. # @return [Symbol, :"thread.run.cancelling"]
  195. 1 required :event, const: :"thread.run.cancelling"
  196. # @!method initialize(data:, event: :"thread.run.cancelling")
  197. # Some parameter documentations has been truncated, see
  198. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelling} for more details.
  199. #
  200. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  201. # moves to a `cancelling` status.
  202. #
  203. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  204. #
  205. # @param event [Symbol, :"thread.run.cancelling"]
  206. end
  207. 1 class ThreadRunCancelled < OpenAI::Internal::Type::BaseModel
  208. # @!attribute data
  209. # Represents an execution run on a
  210. # [thread](https://platform.openai.com/docs/api-reference/threads).
  211. #
  212. # @return [OpenAI::Models::Beta::Threads::Run]
  213. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  214. # @!attribute event
  215. #
  216. # @return [Symbol, :"thread.run.cancelled"]
  217. 1 required :event, const: :"thread.run.cancelled"
  218. # @!method initialize(data:, event: :"thread.run.cancelled")
  219. # Some parameter documentations has been truncated, see
  220. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelled} for more details.
  221. #
  222. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  223. # is cancelled.
  224. #
  225. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  226. #
  227. # @param event [Symbol, :"thread.run.cancelled"]
  228. end
  229. 1 class ThreadRunExpired < OpenAI::Internal::Type::BaseModel
  230. # @!attribute data
  231. # Represents an execution run on a
  232. # [thread](https://platform.openai.com/docs/api-reference/threads).
  233. #
  234. # @return [OpenAI::Models::Beta::Threads::Run]
  235. 1 required :data, -> { OpenAI::Beta::Threads::Run }
  236. # @!attribute event
  237. #
  238. # @return [Symbol, :"thread.run.expired"]
  239. 1 required :event, const: :"thread.run.expired"
  240. # @!method initialize(data:, event: :"thread.run.expired")
  241. # Some parameter documentations has been truncated, see
  242. # {OpenAI::Models::Beta::RunStreamEvent::ThreadRunExpired} for more details.
  243. #
  244. # Occurs when a [run](https://platform.openai.com/docs/api-reference/runs/object)
  245. # expires.
  246. #
  247. # @param data [OpenAI::Models::Beta::Threads::Run] Represents an execution run on a [thread](https://platform.openai.com/docs/api-r
  248. #
  249. # @param event [Symbol, :"thread.run.expired"]
  250. end
  251. # @!method self.variants
  252. # @return [Array(OpenAI::Models::Beta::RunStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::RunStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::RunStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::RunStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::RunStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::RunStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::RunStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::RunStreamEvent::ThreadRunExpired)]
  253. end
  254. end
  255. end
  256. end

openai-ruby/lib/openai/models/beta/thread.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Threads#create
  6. 1 class Thread < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The identifier, which can be referenced in API endpoints.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # The Unix timestamp (in seconds) for when the thread was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute metadata
  18. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  19. # for storing additional information about the object in a structured format, and
  20. # querying for objects via API or the dashboard.
  21. #
  22. # Keys are strings with a maximum length of 64 characters. Values are strings with
  23. # a maximum length of 512 characters.
  24. #
  25. # @return [Hash{Symbol=>String}, nil]
  26. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  27. # @!attribute object
  28. # The object type, which is always `thread`.
  29. #
  30. # @return [Symbol, :thread]
  31. 1 required :object, const: :thread
  32. # @!attribute tool_resources
  33. # A set of resources that are made available to the assistant's tools in this
  34. # thread. The resources are specific to the type of tool. For example, the
  35. # `code_interpreter` tool requires a list of file IDs, while the `file_search`
  36. # tool requires a list of vector store IDs.
  37. #
  38. # @return [OpenAI::Models::Beta::Thread::ToolResources, nil]
  39. 1 required :tool_resources, -> { OpenAI::Beta::Thread::ToolResources }, nil?: true
  40. # @!method initialize(id:, created_at:, metadata:, tool_resources:, object: :thread)
  41. # Some parameter documentations has been truncated, see
  42. # {OpenAI::Models::Beta::Thread} for more details.
  43. #
  44. # Represents a thread that contains
  45. # [messages](https://platform.openai.com/docs/api-reference/messages).
  46. #
  47. # @param id [String] The identifier, which can be referenced in API endpoints.
  48. #
  49. # @param created_at [Integer] The Unix timestamp (in seconds) for when the thread was created.
  50. #
  51. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  52. #
  53. # @param tool_resources [OpenAI::Models::Beta::Thread::ToolResources, nil] A set of resources that are made available to the assistant's tools in this thre
  54. #
  55. # @param object [Symbol, :thread] The object type, which is always `thread`.
  56. # @see OpenAI::Models::Beta::Thread#tool_resources
  57. 1 class ToolResources < OpenAI::Internal::Type::BaseModel
  58. # @!attribute code_interpreter
  59. #
  60. # @return [OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter, nil]
  61. 1 optional :code_interpreter, -> { OpenAI::Beta::Thread::ToolResources::CodeInterpreter }
  62. # @!attribute file_search
  63. #
  64. # @return [OpenAI::Models::Beta::Thread::ToolResources::FileSearch, nil]
  65. 1 optional :file_search, -> { OpenAI::Beta::Thread::ToolResources::FileSearch }
  66. # @!method initialize(code_interpreter: nil, file_search: nil)
  67. # A set of resources that are made available to the assistant's tools in this
  68. # thread. The resources are specific to the type of tool. For example, the
  69. # `code_interpreter` tool requires a list of file IDs, while the `file_search`
  70. # tool requires a list of vector store IDs.
  71. #
  72. # @param code_interpreter [OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter]
  73. # @param file_search [OpenAI::Models::Beta::Thread::ToolResources::FileSearch]
  74. # @see OpenAI::Models::Beta::Thread::ToolResources#code_interpreter
  75. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  76. # @!attribute file_ids
  77. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  78. # available to the `code_interpreter` tool. There can be a maximum of 20 files
  79. # associated with the tool.
  80. #
  81. # @return [Array<String>, nil]
  82. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  83. # @!method initialize(file_ids: nil)
  84. # Some parameter documentations has been truncated, see
  85. # {OpenAI::Models::Beta::Thread::ToolResources::CodeInterpreter} for more details.
  86. #
  87. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  88. end
  89. # @see OpenAI::Models::Beta::Thread::ToolResources#file_search
  90. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  91. # @!attribute vector_store_ids
  92. # The
  93. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  94. # attached to this thread. There can be a maximum of 1 vector store attached to
  95. # the thread.
  96. #
  97. # @return [Array<String>, nil]
  98. 1 optional :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]
  99. # @!method initialize(vector_store_ids: nil)
  100. # Some parameter documentations has been truncated, see
  101. # {OpenAI::Models::Beta::Thread::ToolResources::FileSearch} for more details.
  102. #
  103. # @param vector_store_ids [Array<String>] The [vector store](https://platform.openai.com/docs/api-reference/vector-stores/
  104. end
  105. end
  106. end
  107. end
  108. end
  109. end

openai-ruby/lib/openai/models/beta/thread_create_and_run_params.rb

85.98% lines covered

100.0% branches covered

107 relevant lines. 92 lines covered and 15 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Threads#create_and_run
  6. #
  7. # @see OpenAI::Resources::Beta::Threads#stream_raw
  8. 1 class ThreadCreateAndRunParams < OpenAI::Internal::Type::BaseModel
  9. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  10. 1 include OpenAI::Internal::Type::RequestParameters
  11. # @!attribute assistant_id
  12. # The ID of the
  13. # [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
  14. # execute this run.
  15. #
  16. # @return [String]
  17. 1 required :assistant_id, String
  18. # @!attribute instructions
  19. # Override the default system message of the assistant. This is useful for
  20. # modifying the behavior on a per-run basis.
  21. #
  22. # @return [String, nil]
  23. 1 optional :instructions, String, nil?: true
  24. # @!attribute max_completion_tokens
  25. # The maximum number of completion tokens that may be used over the course of the
  26. # run. The run will make a best effort to use only the number of completion tokens
  27. # specified, across multiple turns of the run. If the run exceeds the number of
  28. # completion tokens specified, the run will end with status `incomplete`. See
  29. # `incomplete_details` for more info.
  30. #
  31. # @return [Integer, nil]
  32. 1 optional :max_completion_tokens, Integer, nil?: true
  33. # @!attribute max_prompt_tokens
  34. # The maximum number of prompt tokens that may be used over the course of the run.
  35. # The run will make a best effort to use only the number of prompt tokens
  36. # specified, across multiple turns of the run. If the run exceeds the number of
  37. # prompt tokens specified, the run will end with status `incomplete`. See
  38. # `incomplete_details` for more info.
  39. #
  40. # @return [Integer, nil]
  41. 1 optional :max_prompt_tokens, Integer, nil?: true
  42. # @!attribute metadata
  43. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  44. # for storing additional information about the object in a structured format, and
  45. # querying for objects via API or the dashboard.
  46. #
  47. # Keys are strings with a maximum length of 64 characters. Values are strings with
  48. # a maximum length of 512 characters.
  49. #
  50. # @return [Hash{Symbol=>String}, nil]
  51. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  52. # @!attribute model
  53. # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
  54. # be used to execute this run. If a value is provided here, it will override the
  55. # model associated with the assistant. If not, the model associated with the
  56. # assistant will be used.
  57. #
  58. # @return [String, Symbol, OpenAI::Models::ChatModel, nil]
  59. 1 optional :model, union: -> { OpenAI::Beta::ThreadCreateAndRunParams::Model }, nil?: true
  60. # @!attribute parallel_tool_calls
  61. # Whether to enable
  62. # [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
  63. # during tool use.
  64. #
  65. # @return [Boolean, nil]
  66. 1 optional :parallel_tool_calls, OpenAI::Internal::Type::Boolean
  67. # @!attribute response_format
  68. # Specifies the format that the model must output. Compatible with
  69. # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  70. # [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  71. # and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  72. #
  73. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  74. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  75. # in the
  76. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  77. #
  78. # Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  79. # message the model generates is valid JSON.
  80. #
  81. # **Important:** when using JSON mode, you **must** also instruct the model to
  82. # produce JSON yourself via a system or user message. Without this, the model may
  83. # generate an unending stream of whitespace until the generation reaches the token
  84. # limit, resulting in a long-running and seemingly "stuck" request. Also note that
  85. # the message content may be partially cut off if `finish_reason="length"`, which
  86. # indicates the generation exceeded `max_tokens` or the conversation exceeded the
  87. # max context length.
  88. #
  89. # @return [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil]
  90. 1 optional :response_format, union: -> { OpenAI::Beta::AssistantResponseFormatOption }, nil?: true
  91. # @!attribute temperature
  92. # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  93. # make the output more random, while lower values like 0.2 will make it more
  94. # focused and deterministic.
  95. #
  96. # @return [Float, nil]
  97. 1 optional :temperature, Float, nil?: true
  98. # @!attribute thread
  99. # Options to create a new thread. If no thread is provided when running a request,
  100. # an empty thread will be created.
  101. #
  102. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread, nil]
  103. 1 optional :thread, -> { OpenAI::Beta::ThreadCreateAndRunParams::Thread }
  104. # @!attribute tool_choice
  105. # Controls which (if any) tool is called by the model. `none` means the model will
  106. # not call any tools and instead generates a message. `auto` is the default value
  107. # and means the model can pick between generating a message or calling one or more
  108. # tools. `required` means the model must call one or more tools before responding
  109. # to the user. Specifying a particular tool like `{"type": "file_search"}` or
  110. # `{"type": "function", "function": {"name": "my_function"}}` forces the model to
  111. # call that tool.
  112. #
  113. # @return [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil]
  114. 1 optional :tool_choice, union: -> { OpenAI::Beta::AssistantToolChoiceOption }, nil?: true
  115. # @!attribute tool_resources
  116. # A set of resources that are used by the assistant's tools. The resources are
  117. # specific to the type of tool. For example, the `code_interpreter` tool requires
  118. # a list of file IDs, while the `file_search` tool requires a list of vector store
  119. # IDs.
  120. #
  121. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources, nil]
  122. 1 optional :tool_resources, -> { OpenAI::Beta::ThreadCreateAndRunParams::ToolResources }, nil?: true
  123. # @!attribute tools
  124. # Override the tools the assistant can use for this run. This is useful for
  125. # modifying the behavior on a per-run basis.
  126. #
  127. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil]
  128. 1 optional :tools,
  129. -> {
  130. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::AssistantTool]
  131. },
  132. nil?: true
  133. # @!attribute top_p
  134. # An alternative to sampling with temperature, called nucleus sampling, where the
  135. # model considers the results of the tokens with top_p probability mass. So 0.1
  136. # means only the tokens comprising the top 10% probability mass are considered.
  137. #
  138. # We generally recommend altering this or temperature but not both.
  139. #
  140. # @return [Float, nil]
  141. 1 optional :top_p, Float, nil?: true
  142. # @!attribute truncation_strategy
  143. # Controls for how a thread will be truncated prior to the run. Use this to
  144. # control the intial context window of the run.
  145. #
  146. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy, nil]
  147. 1 optional :truncation_strategy,
  148. -> { OpenAI::Beta::ThreadCreateAndRunParams::TruncationStrategy },
  149. nil?: true
  150. # @!method initialize(assistant_id:, instructions: nil, max_completion_tokens: nil, max_prompt_tokens: nil, metadata: nil, model: nil, parallel_tool_calls: nil, response_format: nil, temperature: nil, thread: nil, tool_choice: nil, tool_resources: nil, tools: nil, top_p: nil, truncation_strategy: nil, request_options: {})
  151. # Some parameter documentations has been truncated, see
  152. # {OpenAI::Models::Beta::ThreadCreateAndRunParams} for more details.
  153. #
  154. # @param assistant_id [String] The ID of the [assistant](https://platform.openai.com/docs/api-reference/assista
  155. #
  156. # @param instructions [String, nil] Override the default system message of the assistant. This is useful for modifyi
  157. #
  158. # @param max_completion_tokens [Integer, nil] The maximum number of completion tokens that may be used over the course of the
  159. #
  160. # @param max_prompt_tokens [Integer, nil] The maximum number of prompt tokens that may be used over the course of the run.
  161. #
  162. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  163. #
  164. # @param model [String, Symbol, OpenAI::Models::ChatModel, nil] The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
  165. #
  166. # @param parallel_tool_calls [Boolean] Whether to enable [parallel function calling](https://platform.openai.com/docs/g
  167. #
  168. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  169. #
  170. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  171. #
  172. # @param thread [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread] Options to create a new thread. If no thread is provided when running a
  173. #
  174. # @param tool_choice [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil] Controls which (if any) tool is called by the model.
  175. #
  176. # @param tool_resources [OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources, nil] A set of resources that are used by the assistant's tools. The resources are spe
  177. #
  178. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil] Override the tools the assistant can use for this run. This is useful for modify
  179. #
  180. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  181. #
  182. # @param truncation_strategy [OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy, nil] Controls for how a thread will be truncated prior to the run. Use this to contro
  183. #
  184. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  185. # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
  186. # be used to execute this run. If a value is provided here, it will override the
  187. # model associated with the assistant. If not, the model associated with the
  188. # assistant will be used.
  189. 1 module Model
  190. 1 extend OpenAI::Internal::Type::Union
  191. 1 variant String
  192. # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.
  193. 1 variant enum: -> { OpenAI::ChatModel }
  194. # @!method self.variants
  195. # @return [Array(String, Symbol, OpenAI::Models::ChatModel)]
  196. end
  197. 1 class Thread < OpenAI::Internal::Type::BaseModel
  198. # @!attribute messages
  199. # A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
  200. # start the thread with.
  201. #
  202. # @return [Array<OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message>, nil]
  203. 1 optional :messages,
  204. -> {
  205. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::ThreadCreateAndRunParams::Thread::Message]
  206. }
  207. # @!attribute metadata
  208. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  209. # for storing additional information about the object in a structured format, and
  210. # querying for objects via API or the dashboard.
  211. #
  212. # Keys are strings with a maximum length of 64 characters. Values are strings with
  213. # a maximum length of 512 characters.
  214. #
  215. # @return [Hash{Symbol=>String}, nil]
  216. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  217. # @!attribute tool_resources
  218. # A set of resources that are made available to the assistant's tools in this
  219. # thread. The resources are specific to the type of tool. For example, the
  220. # `code_interpreter` tool requires a list of file IDs, while the `file_search`
  221. # tool requires a list of vector store IDs.
  222. #
  223. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources, nil]
  224. 1 optional :tool_resources,
  225. -> {
  226. OpenAI::Beta::ThreadCreateAndRunParams::Thread::ToolResources
  227. },
  228. nil?: true
  229. # @!method initialize(messages: nil, metadata: nil, tool_resources: nil)
  230. # Some parameter documentations has been truncated, see
  231. # {OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread} for more details.
  232. #
  233. # Options to create a new thread. If no thread is provided when running a request,
  234. # an empty thread will be created.
  235. #
  236. # @param messages [Array<OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message>] A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
  237. #
  238. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  239. #
  240. # @param tool_resources [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources, nil] A set of resources that are made available to the assistant's tools in this thre
  241. 1 class Message < OpenAI::Internal::Type::BaseModel
  242. # @!attribute content
  243. # The text contents of the message.
  244. #
  245. # @return [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>]
  246. 1 required :content, union: -> { OpenAI::Beta::ThreadCreateAndRunParams::Thread::Message::Content }
  247. # @!attribute role
  248. # The role of the entity that is creating the message. Allowed values include:
  249. #
  250. # - `user`: Indicates the message is sent by an actual user and should be used in
  251. # most cases to represent user-generated messages.
  252. # - `assistant`: Indicates the message is generated by the assistant. Use this
  253. # value to insert messages from the assistant into the conversation.
  254. #
  255. # @return [Symbol, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role]
  256. 1 required :role, enum: -> { OpenAI::Beta::ThreadCreateAndRunParams::Thread::Message::Role }
  257. # @!attribute attachments
  258. # A list of files attached to the message, and the tools they should be added to.
  259. #
  260. # @return [Array<OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment>, nil]
  261. 1 optional :attachments,
  262. -> {
  263. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment]
  264. },
  265. nil?: true
  266. # @!attribute metadata
  267. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  268. # for storing additional information about the object in a structured format, and
  269. # querying for objects via API or the dashboard.
  270. #
  271. # Keys are strings with a maximum length of 64 characters. Values are strings with
  272. # a maximum length of 512 characters.
  273. #
  274. # @return [Hash{Symbol=>String}, nil]
  275. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  276. # @!method initialize(content:, role:, attachments: nil, metadata: nil)
  277. # Some parameter documentations has been truncated, see
  278. # {OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message} for more
  279. # details.
  280. #
  281. # @param content [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>] The text contents of the message.
  282. #
  283. # @param role [Symbol, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Role] The role of the entity that is creating the message. Allowed values include:
  284. #
  285. # @param attachments [Array<OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment>, nil] A list of files attached to the message, and the tools they should be added to.
  286. #
  287. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  288. # The text contents of the message.
  289. #
  290. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message#content
  291. 1 module Content
  292. 1 extend OpenAI::Internal::Type::Union
  293. # The text contents of the message.
  294. 1 variant String
  295. # An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models).
  296. 1 variant -> { OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Content::MessageContentPartParamArray }
  297. # @!method self.variants
  298. # @return [Array(String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>)]
  299. # @type [OpenAI::Internal::Type::Converter]
  300. MessageContentPartParamArray =
  301. 1 OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Beta::Threads::MessageContentPartParam }]
  302. end
  303. # The role of the entity that is creating the message. Allowed values include:
  304. #
  305. # - `user`: Indicates the message is sent by an actual user and should be used in
  306. # most cases to represent user-generated messages.
  307. # - `assistant`: Indicates the message is generated by the assistant. Use this
  308. # value to insert messages from the assistant into the conversation.
  309. #
  310. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message#role
  311. 1 module Role
  312. 1 extend OpenAI::Internal::Type::Enum
  313. 1 USER = :user
  314. 1 ASSISTANT = :assistant
  315. # @!method self.values
  316. # @return [Array<Symbol>]
  317. end
  318. 1 class Attachment < OpenAI::Internal::Type::BaseModel
  319. # @!attribute file_id
  320. # The ID of the file to attach to the message.
  321. #
  322. # @return [String, nil]
  323. 1 optional :file_id, String
  324. # @!attribute tools
  325. # The tools to add this file to.
  326. #
  327. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch>, nil]
  328. 1 optional :tools,
  329. -> {
  330. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool]
  331. }
  332. # @!method initialize(file_id: nil, tools: nil)
  333. # @param file_id [String] The ID of the file to attach to the message.
  334. #
  335. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch>] The tools to add this file to.
  336. 1 module Tool
  337. 1 extend OpenAI::Internal::Type::Union
  338. 1 discriminator :type
  339. 1 variant :code_interpreter, -> { OpenAI::Beta::CodeInterpreterTool }
  340. 1 variant :file_search,
  341. -> {
  342. OpenAI::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch
  343. }
  344. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  345. # @!attribute type
  346. # The type of tool being defined: `file_search`
  347. #
  348. # @return [Symbol, :file_search]
  349. 1 required :type, const: :file_search
  350. # @!method initialize(type: :file_search)
  351. # @param type [Symbol, :file_search] The type of tool being defined: `file_search`
  352. end
  353. # @!method self.variants
  354. # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::Message::Attachment::Tool::FileSearch)]
  355. end
  356. end
  357. end
  358. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread#tool_resources
  359. 1 class ToolResources < OpenAI::Internal::Type::BaseModel
  360. # @!attribute code_interpreter
  361. #
  362. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter, nil]
  363. 1 optional :code_interpreter,
  364. -> { OpenAI::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter }
  365. # @!attribute file_search
  366. #
  367. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch, nil]
  368. 1 optional :file_search,
  369. -> {
  370. OpenAI::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch
  371. }
  372. # @!method initialize(code_interpreter: nil, file_search: nil)
  373. # A set of resources that are made available to the assistant's tools in this
  374. # thread. The resources are specific to the type of tool. For example, the
  375. # `code_interpreter` tool requires a list of file IDs, while the `file_search`
  376. # tool requires a list of vector store IDs.
  377. #
  378. # @param code_interpreter [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter]
  379. # @param file_search [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch]
  380. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources#code_interpreter
  381. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  382. # @!attribute file_ids
  383. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  384. # available to the `code_interpreter` tool. There can be a maximum of 20 files
  385. # associated with the tool.
  386. #
  387. # @return [Array<String>, nil]
  388. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  389. # @!method initialize(file_ids: nil)
  390. # Some parameter documentations has been truncated, see
  391. # {OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::CodeInterpreter}
  392. # for more details.
  393. #
  394. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  395. end
  396. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources#file_search
  397. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  398. # @!attribute vector_store_ids
  399. # The
  400. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  401. # attached to this thread. There can be a maximum of 1 vector store attached to
  402. # the thread.
  403. #
  404. # @return [Array<String>, nil]
  405. 1 optional :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]
  406. # @!attribute vector_stores
  407. # A helper to create a
  408. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  409. # with file_ids and attach it to this thread. There can be a maximum of 1 vector
  410. # store attached to the thread.
  411. #
  412. # @return [Array<OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore>, nil]
  413. 1 optional :vector_stores,
  414. -> {
  415. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore]
  416. }
  417. # @!method initialize(vector_store_ids: nil, vector_stores: nil)
  418. # Some parameter documentations has been truncated, see
  419. # {OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch}
  420. # for more details.
  421. #
  422. # @param vector_store_ids [Array<String>] The [vector store](https://platform.openai.com/docs/api-reference/vector-stores/
  423. #
  424. # @param vector_stores [Array<OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore>] A helper to create a [vector store](https://platform.openai.com/docs/api-referen
  425. 1 class VectorStore < OpenAI::Internal::Type::BaseModel
  426. # @!attribute chunking_strategy
  427. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  428. # strategy.
  429. #
  430. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static, nil]
  431. 1 optional :chunking_strategy,
  432. union: -> {
  433. OpenAI::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy
  434. }
  435. # @!attribute file_ids
  436. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
  437. # add to the vector store. There can be a maximum of 10000 files in a vector
  438. # store.
  439. #
  440. # @return [Array<String>, nil]
  441. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  442. # @!attribute metadata
  443. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  444. # for storing additional information about the object in a structured format, and
  445. # querying for objects via API or the dashboard.
  446. #
  447. # Keys are strings with a maximum length of 64 characters. Values are strings with
  448. # a maximum length of 512 characters.
  449. #
  450. # @return [Hash{Symbol=>String}, nil]
  451. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  452. # @!method initialize(chunking_strategy: nil, file_ids: nil, metadata: nil)
  453. # Some parameter documentations has been truncated, see
  454. # {OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore}
  455. # for more details.
  456. #
  457. # @param chunking_strategy [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  458. #
  459. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to ad
  460. #
  461. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  462. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  463. # strategy.
  464. #
  465. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore#chunking_strategy
  466. 1 module ChunkingStrategy
  467. 1 extend OpenAI::Internal::Type::Union
  468. 1 discriminator :type
  469. # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
  470. 1 variant :auto,
  471. -> {
  472. OpenAI::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto
  473. }
  474. 1 variant :static,
  475. -> {
  476. OpenAI::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static
  477. }
  478. 1 class Auto < OpenAI::Internal::Type::BaseModel
  479. # @!attribute type
  480. # Always `auto`.
  481. #
  482. # @return [Symbol, :auto]
  483. 1 required :type, const: :auto
  484. # @!method initialize(type: :auto)
  485. # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
  486. # `800` and `chunk_overlap_tokens` of `400`.
  487. #
  488. # @param type [Symbol, :auto] Always `auto`.
  489. end
  490. 1 class Static < OpenAI::Internal::Type::BaseModel
  491. # @!attribute static
  492. #
  493. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static]
  494. 1 required :static,
  495. -> {
  496. OpenAI::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static
  497. }
  498. # @!attribute type
  499. # Always `static`.
  500. #
  501. # @return [Symbol, :static]
  502. 1 required :type, const: :static
  503. # @!method initialize(static:, type: :static)
  504. # @param static [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static]
  505. #
  506. # @param type [Symbol, :static] Always `static`.
  507. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static#static
  508. 1 class Static < OpenAI::Internal::Type::BaseModel
  509. # @!attribute chunk_overlap_tokens
  510. # The number of tokens that overlap between chunks. The default value is `400`.
  511. #
  512. # Note that the overlap must not exceed half of `max_chunk_size_tokens`.
  513. #
  514. # @return [Integer]
  515. 1 required :chunk_overlap_tokens, Integer
  516. # @!attribute max_chunk_size_tokens
  517. # The maximum number of tokens in each chunk. The default value is `800`. The
  518. # minimum value is `100` and the maximum value is `4096`.
  519. #
  520. # @return [Integer]
  521. 1 required :max_chunk_size_tokens, Integer
  522. # @!method initialize(chunk_overlap_tokens:, max_chunk_size_tokens:)
  523. # Some parameter documentations has been truncated, see
  524. # {OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static}
  525. # for more details.
  526. #
  527. # @param chunk_overlap_tokens [Integer] The number of tokens that overlap between chunks. The default value is `400`.
  528. #
  529. # @param max_chunk_size_tokens [Integer] The maximum number of tokens in each chunk. The default value is `800`. The mini
  530. end
  531. end
  532. # @!method self.variants
  533. # @return [Array(OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)]
  534. end
  535. end
  536. end
  537. end
  538. end
  539. 1 class ToolResources < OpenAI::Internal::Type::BaseModel
  540. # @!attribute code_interpreter
  541. #
  542. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter, nil]
  543. 1 optional :code_interpreter,
  544. -> {
  545. OpenAI::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter
  546. }
  547. # @!attribute file_search
  548. #
  549. # @return [OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch, nil]
  550. 1 optional :file_search, -> { OpenAI::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch }
  551. # @!method initialize(code_interpreter: nil, file_search: nil)
  552. # A set of resources that are used by the assistant's tools. The resources are
  553. # specific to the type of tool. For example, the `code_interpreter` tool requires
  554. # a list of file IDs, while the `file_search` tool requires a list of vector store
  555. # IDs.
  556. #
  557. # @param code_interpreter [OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter]
  558. # @param file_search [OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch]
  559. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources#code_interpreter
  560. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  561. # @!attribute file_ids
  562. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  563. # available to the `code_interpreter` tool. There can be a maximum of 20 files
  564. # associated with the tool.
  565. #
  566. # @return [Array<String>, nil]
  567. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  568. # @!method initialize(file_ids: nil)
  569. # Some parameter documentations has been truncated, see
  570. # {OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::CodeInterpreter}
  571. # for more details.
  572. #
  573. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  574. end
  575. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources#file_search
  576. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  577. # @!attribute vector_store_ids
  578. # The ID of the
  579. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  580. # attached to this assistant. There can be a maximum of 1 vector store attached to
  581. # the assistant.
  582. #
  583. # @return [Array<String>, nil]
  584. 1 optional :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]
  585. # @!method initialize(vector_store_ids: nil)
  586. # Some parameter documentations has been truncated, see
  587. # {OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources::FileSearch} for
  588. # more details.
  589. #
  590. # @param vector_store_ids [Array<String>] The ID of the [vector store](https://platform.openai.com/docs/api-reference/vect
  591. end
  592. end
  593. 1 class TruncationStrategy < OpenAI::Internal::Type::BaseModel
  594. # @!attribute type
  595. # The truncation strategy to use for the thread. The default is `auto`. If set to
  596. # `last_messages`, the thread will be truncated to the n most recent messages in
  597. # the thread. When set to `auto`, messages in the middle of the thread will be
  598. # dropped to fit the context length of the model, `max_prompt_tokens`.
  599. #
  600. # @return [Symbol, OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type]
  601. 1 required :type, enum: -> { OpenAI::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type }
  602. # @!attribute last_messages
  603. # The number of most recent messages from the thread when constructing the context
  604. # for the run.
  605. #
  606. # @return [Integer, nil]
  607. 1 optional :last_messages, Integer, nil?: true
  608. # @!method initialize(type:, last_messages: nil)
  609. # Some parameter documentations has been truncated, see
  610. # {OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy} for more
  611. # details.
  612. #
  613. # Controls for how a thread will be truncated prior to the run. Use this to
  614. # control the intial context window of the run.
  615. #
  616. # @param type [Symbol, OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy::Type] The truncation strategy to use for the thread. The default is `auto`. If set to
  617. #
  618. # @param last_messages [Integer, nil] The number of most recent messages from the thread when constructing the context
  619. # The truncation strategy to use for the thread. The default is `auto`. If set to
  620. # `last_messages`, the thread will be truncated to the n most recent messages in
  621. # the thread. When set to `auto`, messages in the middle of the thread will be
  622. # dropped to fit the context length of the model, `max_prompt_tokens`.
  623. #
  624. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy#type
  625. 1 module Type
  626. 1 extend OpenAI::Internal::Type::Enum
  627. 1 AUTO = :auto
  628. 1 LAST_MESSAGES = :last_messages
  629. # @!method self.values
  630. # @return [Array<Symbol>]
  631. end
  632. end
  633. end
  634. end
  635. end
  636. end

openai-ruby/lib/openai/models/beta/thread_create_params.rb

87.88% lines covered

100.0% branches covered

66 relevant lines. 58 lines covered and 8 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Threads#create
  6. 1 class ThreadCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute messages
  10. # A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
  11. # start the thread with.
  12. #
  13. # @return [Array<OpenAI::Models::Beta::ThreadCreateParams::Message>, nil]
  14. 1 optional :messages, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::ThreadCreateParams::Message] }
  15. # @!attribute metadata
  16. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  17. # for storing additional information about the object in a structured format, and
  18. # querying for objects via API or the dashboard.
  19. #
  20. # Keys are strings with a maximum length of 64 characters. Values are strings with
  21. # a maximum length of 512 characters.
  22. #
  23. # @return [Hash{Symbol=>String}, nil]
  24. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  25. # @!attribute tool_resources
  26. # A set of resources that are made available to the assistant's tools in this
  27. # thread. The resources are specific to the type of tool. For example, the
  28. # `code_interpreter` tool requires a list of file IDs, while the `file_search`
  29. # tool requires a list of vector store IDs.
  30. #
  31. # @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources, nil]
  32. 1 optional :tool_resources, -> { OpenAI::Beta::ThreadCreateParams::ToolResources }, nil?: true
  33. # @!method initialize(messages: nil, metadata: nil, tool_resources: nil, request_options: {})
  34. # Some parameter documentations has been truncated, see
  35. # {OpenAI::Models::Beta::ThreadCreateParams} for more details.
  36. #
  37. # @param messages [Array<OpenAI::Models::Beta::ThreadCreateParams::Message>] A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
  38. #
  39. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  40. #
  41. # @param tool_resources [OpenAI::Models::Beta::ThreadCreateParams::ToolResources, nil] A set of resources that are made available to the assistant's tools in this thre
  42. #
  43. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  44. 1 class Message < OpenAI::Internal::Type::BaseModel
  45. # @!attribute content
  46. # The text contents of the message.
  47. #
  48. # @return [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>]
  49. 1 required :content, union: -> { OpenAI::Beta::ThreadCreateParams::Message::Content }
  50. # @!attribute role
  51. # The role of the entity that is creating the message. Allowed values include:
  52. #
  53. # - `user`: Indicates the message is sent by an actual user and should be used in
  54. # most cases to represent user-generated messages.
  55. # - `assistant`: Indicates the message is generated by the assistant. Use this
  56. # value to insert messages from the assistant into the conversation.
  57. #
  58. # @return [Symbol, OpenAI::Models::Beta::ThreadCreateParams::Message::Role]
  59. 1 required :role, enum: -> { OpenAI::Beta::ThreadCreateParams::Message::Role }
  60. # @!attribute attachments
  61. # A list of files attached to the message, and the tools they should be added to.
  62. #
  63. # @return [Array<OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment>, nil]
  64. 1 optional :attachments,
  65. -> {
  66. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::ThreadCreateParams::Message::Attachment]
  67. },
  68. nil?: true
  69. # @!attribute metadata
  70. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  71. # for storing additional information about the object in a structured format, and
  72. # querying for objects via API or the dashboard.
  73. #
  74. # Keys are strings with a maximum length of 64 characters. Values are strings with
  75. # a maximum length of 512 characters.
  76. #
  77. # @return [Hash{Symbol=>String}, nil]
  78. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  79. # @!method initialize(content:, role:, attachments: nil, metadata: nil)
  80. # Some parameter documentations has been truncated, see
  81. # {OpenAI::Models::Beta::ThreadCreateParams::Message} for more details.
  82. #
  83. # @param content [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>] The text contents of the message.
  84. #
  85. # @param role [Symbol, OpenAI::Models::Beta::ThreadCreateParams::Message::Role] The role of the entity that is creating the message. Allowed values include:
  86. #
  87. # @param attachments [Array<OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment>, nil] A list of files attached to the message, and the tools they should be added to.
  88. #
  89. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  90. # The text contents of the message.
  91. #
  92. # @see OpenAI::Models::Beta::ThreadCreateParams::Message#content
  93. 1 module Content
  94. 1 extend OpenAI::Internal::Type::Union
  95. # The text contents of the message.
  96. 1 variant String
  97. # An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models).
  98. 1 variant -> { OpenAI::Models::Beta::ThreadCreateParams::Message::Content::MessageContentPartParamArray }
  99. # @!method self.variants
  100. # @return [Array(String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>)]
  101. # @type [OpenAI::Internal::Type::Converter]
  102. MessageContentPartParamArray =
  103. 1 OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Beta::Threads::MessageContentPartParam }]
  104. end
  105. # The role of the entity that is creating the message. Allowed values include:
  106. #
  107. # - `user`: Indicates the message is sent by an actual user and should be used in
  108. # most cases to represent user-generated messages.
  109. # - `assistant`: Indicates the message is generated by the assistant. Use this
  110. # value to insert messages from the assistant into the conversation.
  111. #
  112. # @see OpenAI::Models::Beta::ThreadCreateParams::Message#role
  113. 1 module Role
  114. 1 extend OpenAI::Internal::Type::Enum
  115. 1 USER = :user
  116. 1 ASSISTANT = :assistant
  117. # @!method self.values
  118. # @return [Array<Symbol>]
  119. end
  120. 1 class Attachment < OpenAI::Internal::Type::BaseModel
  121. # @!attribute file_id
  122. # The ID of the file to attach to the message.
  123. #
  124. # @return [String, nil]
  125. 1 optional :file_id, String
  126. # @!attribute tools
  127. # The tools to add this file to.
  128. #
  129. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch>, nil]
  130. 1 optional :tools,
  131. -> {
  132. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::ThreadCreateParams::Message::Attachment::Tool]
  133. }
  134. # @!method initialize(file_id: nil, tools: nil)
  135. # @param file_id [String] The ID of the file to attach to the message.
  136. #
  137. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch>] The tools to add this file to.
  138. 1 module Tool
  139. 1 extend OpenAI::Internal::Type::Union
  140. 1 discriminator :type
  141. 1 variant :code_interpreter, -> { OpenAI::Beta::CodeInterpreterTool }
  142. 1 variant :file_search,
  143. -> {
  144. OpenAI::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch
  145. }
  146. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  147. # @!attribute type
  148. # The type of tool being defined: `file_search`
  149. #
  150. # @return [Symbol, :file_search]
  151. 1 required :type, const: :file_search
  152. # @!method initialize(type: :file_search)
  153. # @param type [Symbol, :file_search] The type of tool being defined: `file_search`
  154. end
  155. # @!method self.variants
  156. # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::ThreadCreateParams::Message::Attachment::Tool::FileSearch)]
  157. end
  158. end
  159. end
  160. 1 class ToolResources < OpenAI::Internal::Type::BaseModel
  161. # @!attribute code_interpreter
  162. #
  163. # @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter, nil]
  164. 1 optional :code_interpreter, -> { OpenAI::Beta::ThreadCreateParams::ToolResources::CodeInterpreter }
  165. # @!attribute file_search
  166. #
  167. # @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch, nil]
  168. 1 optional :file_search, -> { OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch }
  169. # @!method initialize(code_interpreter: nil, file_search: nil)
  170. # A set of resources that are made available to the assistant's tools in this
  171. # thread. The resources are specific to the type of tool. For example, the
  172. # `code_interpreter` tool requires a list of file IDs, while the `file_search`
  173. # tool requires a list of vector store IDs.
  174. #
  175. # @param code_interpreter [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter]
  176. # @param file_search [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch]
  177. # @see OpenAI::Models::Beta::ThreadCreateParams::ToolResources#code_interpreter
  178. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  179. # @!attribute file_ids
  180. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  181. # available to the `code_interpreter` tool. There can be a maximum of 20 files
  182. # associated with the tool.
  183. #
  184. # @return [Array<String>, nil]
  185. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  186. # @!method initialize(file_ids: nil)
  187. # Some parameter documentations has been truncated, see
  188. # {OpenAI::Models::Beta::ThreadCreateParams::ToolResources::CodeInterpreter} for
  189. # more details.
  190. #
  191. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  192. end
  193. # @see OpenAI::Models::Beta::ThreadCreateParams::ToolResources#file_search
  194. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  195. # @!attribute vector_store_ids
  196. # The
  197. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  198. # attached to this thread. There can be a maximum of 1 vector store attached to
  199. # the thread.
  200. #
  201. # @return [Array<String>, nil]
  202. 1 optional :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]
  203. # @!attribute vector_stores
  204. # A helper to create a
  205. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  206. # with file_ids and attach it to this thread. There can be a maximum of 1 vector
  207. # store attached to the thread.
  208. #
  209. # @return [Array<OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore>, nil]
  210. 1 optional :vector_stores,
  211. -> {
  212. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore]
  213. }
  214. # @!method initialize(vector_store_ids: nil, vector_stores: nil)
  215. # Some parameter documentations has been truncated, see
  216. # {OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch} for more
  217. # details.
  218. #
  219. # @param vector_store_ids [Array<String>] The [vector store](https://platform.openai.com/docs/api-reference/vector-stores/
  220. #
  221. # @param vector_stores [Array<OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore>] A helper to create a [vector store](https://platform.openai.com/docs/api-referen
  222. 1 class VectorStore < OpenAI::Internal::Type::BaseModel
  223. # @!attribute chunking_strategy
  224. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  225. # strategy.
  226. #
  227. # @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static, nil]
  228. 1 optional :chunking_strategy,
  229. union: -> {
  230. OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy
  231. }
  232. # @!attribute file_ids
  233. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to
  234. # add to the vector store. There can be a maximum of 10000 files in a vector
  235. # store.
  236. #
  237. # @return [Array<String>, nil]
  238. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  239. # @!attribute metadata
  240. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  241. # for storing additional information about the object in a structured format, and
  242. # querying for objects via API or the dashboard.
  243. #
  244. # Keys are strings with a maximum length of 64 characters. Values are strings with
  245. # a maximum length of 512 characters.
  246. #
  247. # @return [Hash{Symbol=>String}, nil]
  248. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  249. # @!method initialize(chunking_strategy: nil, file_ids: nil, metadata: nil)
  250. # Some parameter documentations has been truncated, see
  251. # {OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore}
  252. # for more details.
  253. #
  254. # @param chunking_strategy [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  255. #
  256. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs to ad
  257. #
  258. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  259. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  260. # strategy.
  261. #
  262. # @see OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore#chunking_strategy
  263. 1 module ChunkingStrategy
  264. 1 extend OpenAI::Internal::Type::Union
  265. 1 discriminator :type
  266. # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
  267. 1 variant :auto,
  268. -> {
  269. OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto
  270. }
  271. 1 variant :static,
  272. -> {
  273. OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static
  274. }
  275. 1 class Auto < OpenAI::Internal::Type::BaseModel
  276. # @!attribute type
  277. # Always `auto`.
  278. #
  279. # @return [Symbol, :auto]
  280. 1 required :type, const: :auto
  281. # @!method initialize(type: :auto)
  282. # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of
  283. # `800` and `chunk_overlap_tokens` of `400`.
  284. #
  285. # @param type [Symbol, :auto] Always `auto`.
  286. end
  287. 1 class Static < OpenAI::Internal::Type::BaseModel
  288. # @!attribute static
  289. #
  290. # @return [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static]
  291. 1 required :static,
  292. -> {
  293. OpenAI::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static
  294. }
  295. # @!attribute type
  296. # Always `static`.
  297. #
  298. # @return [Symbol, :static]
  299. 1 required :type, const: :static
  300. # @!method initialize(static:, type: :static)
  301. # @param static [OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static]
  302. #
  303. # @param type [Symbol, :static] Always `static`.
  304. # @see OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static#static
  305. 1 class Static < OpenAI::Internal::Type::BaseModel
  306. # @!attribute chunk_overlap_tokens
  307. # The number of tokens that overlap between chunks. The default value is `400`.
  308. #
  309. # Note that the overlap must not exceed half of `max_chunk_size_tokens`.
  310. #
  311. # @return [Integer]
  312. 1 required :chunk_overlap_tokens, Integer
  313. # @!attribute max_chunk_size_tokens
  314. # The maximum number of tokens in each chunk. The default value is `800`. The
  315. # minimum value is `100` and the maximum value is `4096`.
  316. #
  317. # @return [Integer]
  318. 1 required :max_chunk_size_tokens, Integer
  319. # @!method initialize(chunk_overlap_tokens:, max_chunk_size_tokens:)
  320. # Some parameter documentations has been truncated, see
  321. # {OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static::Static}
  322. # for more details.
  323. #
  324. # @param chunk_overlap_tokens [Integer] The number of tokens that overlap between chunks. The default value is `400`.
  325. #
  326. # @param max_chunk_size_tokens [Integer] The maximum number of tokens in each chunk. The default value is `800`. The mini
  327. end
  328. end
  329. # @!method self.variants
  330. # @return [Array(OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Auto, OpenAI::Models::Beta::ThreadCreateParams::ToolResources::FileSearch::VectorStore::ChunkingStrategy::Static)]
  331. end
  332. end
  333. end
  334. end
  335. end
  336. end
  337. end
  338. end

openai-ruby/lib/openai/models/beta/thread_delete_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Threads#delete
  6. 1 class ThreadDeleteParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/beta/thread_deleted.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Threads#delete
  6. 1 class ThreadDeleted < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute deleted
  12. #
  13. # @return [Boolean]
  14. 1 required :deleted, OpenAI::Internal::Type::Boolean
  15. # @!attribute object
  16. #
  17. # @return [Symbol, :"thread.deleted"]
  18. 1 required :object, const: :"thread.deleted"
  19. # @!method initialize(id:, deleted:, object: :"thread.deleted")
  20. # @param id [String]
  21. # @param deleted [Boolean]
  22. # @param object [Symbol, :"thread.deleted"]
  23. end
  24. end
  25. end
  26. end

openai-ruby/lib/openai/models/beta/thread_retrieve_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Threads#retrieve
  6. 1 class ThreadRetrieveParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/beta/thread_stream_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 class ThreadStreamEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute data
  7. # Represents a thread that contains
  8. # [messages](https://platform.openai.com/docs/api-reference/messages).
  9. #
  10. # @return [OpenAI::Models::Beta::Thread]
  11. 1 required :data, -> { OpenAI::Beta::Thread }
  12. # @!attribute event
  13. #
  14. # @return [Symbol, :"thread.created"]
  15. 1 required :event, const: :"thread.created"
  16. # @!attribute enabled
  17. # Whether to enable input audio transcription.
  18. #
  19. # @return [Boolean, nil]
  20. 1 optional :enabled, OpenAI::Internal::Type::Boolean
  21. # @!method initialize(data:, enabled: nil, event: :"thread.created")
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Beta::ThreadStreamEvent} for more details.
  24. #
  25. # Occurs when a new
  26. # [thread](https://platform.openai.com/docs/api-reference/threads/object) is
  27. # created.
  28. #
  29. # @param data [OpenAI::Models::Beta::Thread] Represents a thread that contains [messages](https://platform.openai.com/docs/ap
  30. #
  31. # @param enabled [Boolean] Whether to enable input audio transcription.
  32. #
  33. # @param event [Symbol, :"thread.created"]
  34. end
  35. end
  36. end
  37. end

openai-ruby/lib/openai/models/beta/thread_update_params.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. # @see OpenAI::Resources::Beta::Threads#update
  6. 1 class ThreadUpdateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute metadata
  10. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  11. # for storing additional information about the object in a structured format, and
  12. # querying for objects via API or the dashboard.
  13. #
  14. # Keys are strings with a maximum length of 64 characters. Values are strings with
  15. # a maximum length of 512 characters.
  16. #
  17. # @return [Hash{Symbol=>String}, nil]
  18. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  19. # @!attribute tool_resources
  20. # A set of resources that are made available to the assistant's tools in this
  21. # thread. The resources are specific to the type of tool. For example, the
  22. # `code_interpreter` tool requires a list of file IDs, while the `file_search`
  23. # tool requires a list of vector store IDs.
  24. #
  25. # @return [OpenAI::Models::Beta::ThreadUpdateParams::ToolResources, nil]
  26. 1 optional :tool_resources, -> { OpenAI::Beta::ThreadUpdateParams::ToolResources }, nil?: true
  27. # @!method initialize(metadata: nil, tool_resources: nil, request_options: {})
  28. # Some parameter documentations has been truncated, see
  29. # {OpenAI::Models::Beta::ThreadUpdateParams} for more details.
  30. #
  31. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  32. #
  33. # @param tool_resources [OpenAI::Models::Beta::ThreadUpdateParams::ToolResources, nil] A set of resources that are made available to the assistant's tools in this thre
  34. #
  35. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  36. 1 class ToolResources < OpenAI::Internal::Type::BaseModel
  37. # @!attribute code_interpreter
  38. #
  39. # @return [OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter, nil]
  40. 1 optional :code_interpreter, -> { OpenAI::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter }
  41. # @!attribute file_search
  42. #
  43. # @return [OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch, nil]
  44. 1 optional :file_search, -> { OpenAI::Beta::ThreadUpdateParams::ToolResources::FileSearch }
  45. # @!method initialize(code_interpreter: nil, file_search: nil)
  46. # A set of resources that are made available to the assistant's tools in this
  47. # thread. The resources are specific to the type of tool. For example, the
  48. # `code_interpreter` tool requires a list of file IDs, while the `file_search`
  49. # tool requires a list of vector store IDs.
  50. #
  51. # @param code_interpreter [OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter]
  52. # @param file_search [OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch]
  53. # @see OpenAI::Models::Beta::ThreadUpdateParams::ToolResources#code_interpreter
  54. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  55. # @!attribute file_ids
  56. # A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  57. # available to the `code_interpreter` tool. There can be a maximum of 20 files
  58. # associated with the tool.
  59. #
  60. # @return [Array<String>, nil]
  61. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  62. # @!method initialize(file_ids: nil)
  63. # Some parameter documentations has been truncated, see
  64. # {OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::CodeInterpreter} for
  65. # more details.
  66. #
  67. # @param file_ids [Array<String>] A list of [file](https://platform.openai.com/docs/api-reference/files) IDs made
  68. end
  69. # @see OpenAI::Models::Beta::ThreadUpdateParams::ToolResources#file_search
  70. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  71. # @!attribute vector_store_ids
  72. # The
  73. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  74. # attached to this thread. There can be a maximum of 1 vector store attached to
  75. # the thread.
  76. #
  77. # @return [Array<String>, nil]
  78. 1 optional :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]
  79. # @!method initialize(vector_store_ids: nil)
  80. # Some parameter documentations has been truncated, see
  81. # {OpenAI::Models::Beta::ThreadUpdateParams::ToolResources::FileSearch} for more
  82. # details.
  83. #
  84. # @param vector_store_ids [Array<String>] The [vector store](https://platform.openai.com/docs/api-reference/vector-stores/
  85. end
  86. end
  87. end
  88. end
  89. end
  90. end

openai-ruby/lib/openai/models/beta/threads/annotation.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # A citation within the message that points to a specific quote from a specific
  7. # File associated with the assistant or the message. Generated when the assistant
  8. # uses the "file_search" tool to search files.
  9. 1 module Annotation
  10. 1 extend OpenAI::Internal::Type::Union
  11. 1 discriminator :type
  12. # A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.
  13. 1 variant :file_citation, -> { OpenAI::Beta::Threads::FileCitationAnnotation }
  14. # A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.
  15. 1 variant :file_path, -> { OpenAI::Beta::Threads::FilePathAnnotation }
  16. # @!method self.variants
  17. # @return [Array(OpenAI::Models::Beta::Threads::FileCitationAnnotation, OpenAI::Models::Beta::Threads::FilePathAnnotation)]
  18. end
  19. end
  20. end
  21. end
  22. end

openai-ruby/lib/openai/models/beta/threads/annotation_delta.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # A citation within the message that points to a specific quote from a specific
  7. # File associated with the assistant or the message. Generated when the assistant
  8. # uses the "file_search" tool to search files.
  9. 1 module AnnotationDelta
  10. 1 extend OpenAI::Internal::Type::Union
  11. 1 discriminator :type
  12. # A citation within the message that points to a specific quote from a specific File associated with the assistant or the message. Generated when the assistant uses the "file_search" tool to search files.
  13. 1 variant :file_citation, -> { OpenAI::Beta::Threads::FileCitationDeltaAnnotation }
  14. # A URL for the file that's generated when the assistant used the `code_interpreter` tool to generate a file.
  15. 1 variant :file_path, -> { OpenAI::Beta::Threads::FilePathDeltaAnnotation }
  16. # @!method self.variants
  17. # @return [Array(OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation)]
  18. end
  19. end
  20. end
  21. end
  22. end

openai-ruby/lib/openai/models/beta/threads/file_citation_annotation.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class FileCitationAnnotation < OpenAI::Internal::Type::BaseModel
  7. # @!attribute end_index
  8. #
  9. # @return [Integer]
  10. 1 required :end_index, Integer
  11. # @!attribute file_citation
  12. #
  13. # @return [OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation]
  14. 1 required :file_citation, -> { OpenAI::Beta::Threads::FileCitationAnnotation::FileCitation }
  15. # @!attribute start_index
  16. #
  17. # @return [Integer]
  18. 1 required :start_index, Integer
  19. # @!attribute text
  20. # The text in the message content that needs to be replaced.
  21. #
  22. # @return [String]
  23. 1 required :text, String
  24. # @!attribute type
  25. # Always `file_citation`.
  26. #
  27. # @return [Symbol, :file_citation]
  28. 1 required :type, const: :file_citation
  29. # @!method initialize(end_index:, file_citation:, start_index:, text:, type: :file_citation)
  30. # A citation within the message that points to a specific quote from a specific
  31. # File associated with the assistant or the message. Generated when the assistant
  32. # uses the "file_search" tool to search files.
  33. #
  34. # @param end_index [Integer]
  35. #
  36. # @param file_citation [OpenAI::Models::Beta::Threads::FileCitationAnnotation::FileCitation]
  37. #
  38. # @param start_index [Integer]
  39. #
  40. # @param text [String] The text in the message content that needs to be replaced.
  41. #
  42. # @param type [Symbol, :file_citation] Always `file_citation`.
  43. # @see OpenAI::Models::Beta::Threads::FileCitationAnnotation#file_citation
  44. 1 class FileCitation < OpenAI::Internal::Type::BaseModel
  45. # @!attribute file_id
  46. # The ID of the specific File the citation is from.
  47. #
  48. # @return [String]
  49. 1 required :file_id, String
  50. # @!method initialize(file_id:)
  51. # @param file_id [String] The ID of the specific File the citation is from.
  52. end
  53. end
  54. end
  55. end
  56. end
  57. end

openai-ruby/lib/openai/models/beta/threads/file_citation_delta_annotation.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class FileCitationDeltaAnnotation < OpenAI::Internal::Type::BaseModel
  7. # @!attribute index
  8. # The index of the annotation in the text content part.
  9. #
  10. # @return [Integer]
  11. 1 required :index, Integer
  12. # @!attribute type
  13. # Always `file_citation`.
  14. #
  15. # @return [Symbol, :file_citation]
  16. 1 required :type, const: :file_citation
  17. # @!attribute end_index
  18. #
  19. # @return [Integer, nil]
  20. 1 optional :end_index, Integer
  21. # @!attribute file_citation
  22. #
  23. # @return [OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation, nil]
  24. 1 optional :file_citation, -> { OpenAI::Beta::Threads::FileCitationDeltaAnnotation::FileCitation }
  25. # @!attribute start_index
  26. #
  27. # @return [Integer, nil]
  28. 1 optional :start_index, Integer
  29. # @!attribute text
  30. # The text in the message content that needs to be replaced.
  31. #
  32. # @return [String, nil]
  33. 1 optional :text, String
  34. # @!method initialize(index:, end_index: nil, file_citation: nil, start_index: nil, text: nil, type: :file_citation)
  35. # A citation within the message that points to a specific quote from a specific
  36. # File associated with the assistant or the message. Generated when the assistant
  37. # uses the "file_search" tool to search files.
  38. #
  39. # @param index [Integer] The index of the annotation in the text content part.
  40. #
  41. # @param end_index [Integer]
  42. #
  43. # @param file_citation [OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation::FileCitation]
  44. #
  45. # @param start_index [Integer]
  46. #
  47. # @param text [String] The text in the message content that needs to be replaced.
  48. #
  49. # @param type [Symbol, :file_citation] Always `file_citation`.
  50. # @see OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation#file_citation
  51. 1 class FileCitation < OpenAI::Internal::Type::BaseModel
  52. # @!attribute file_id
  53. # The ID of the specific File the citation is from.
  54. #
  55. # @return [String, nil]
  56. 1 optional :file_id, String
  57. # @!attribute quote
  58. # The specific quote in the file.
  59. #
  60. # @return [String, nil]
  61. 1 optional :quote, String
  62. # @!method initialize(file_id: nil, quote: nil)
  63. # @param file_id [String] The ID of the specific File the citation is from.
  64. #
  65. # @param quote [String] The specific quote in the file.
  66. end
  67. end
  68. end
  69. end
  70. end
  71. end

openai-ruby/lib/openai/models/beta/threads/file_path_annotation.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class FilePathAnnotation < OpenAI::Internal::Type::BaseModel
  7. # @!attribute end_index
  8. #
  9. # @return [Integer]
  10. 1 required :end_index, Integer
  11. # @!attribute file_path
  12. #
  13. # @return [OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath]
  14. 1 required :file_path, -> { OpenAI::Beta::Threads::FilePathAnnotation::FilePath }
  15. # @!attribute start_index
  16. #
  17. # @return [Integer]
  18. 1 required :start_index, Integer
  19. # @!attribute text
  20. # The text in the message content that needs to be replaced.
  21. #
  22. # @return [String]
  23. 1 required :text, String
  24. # @!attribute type
  25. # Always `file_path`.
  26. #
  27. # @return [Symbol, :file_path]
  28. 1 required :type, const: :file_path
  29. # @!method initialize(end_index:, file_path:, start_index:, text:, type: :file_path)
  30. # A URL for the file that's generated when the assistant used the
  31. # `code_interpreter` tool to generate a file.
  32. #
  33. # @param end_index [Integer]
  34. #
  35. # @param file_path [OpenAI::Models::Beta::Threads::FilePathAnnotation::FilePath]
  36. #
  37. # @param start_index [Integer]
  38. #
  39. # @param text [String] The text in the message content that needs to be replaced.
  40. #
  41. # @param type [Symbol, :file_path] Always `file_path`.
  42. # @see OpenAI::Models::Beta::Threads::FilePathAnnotation#file_path
  43. 1 class FilePath < OpenAI::Internal::Type::BaseModel
  44. # @!attribute file_id
  45. # The ID of the file that was generated.
  46. #
  47. # @return [String]
  48. 1 required :file_id, String
  49. # @!method initialize(file_id:)
  50. # @param file_id [String] The ID of the file that was generated.
  51. end
  52. end
  53. end
  54. end
  55. end
  56. end

openai-ruby/lib/openai/models/beta/threads/file_path_delta_annotation.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class FilePathDeltaAnnotation < OpenAI::Internal::Type::BaseModel
  7. # @!attribute index
  8. # The index of the annotation in the text content part.
  9. #
  10. # @return [Integer]
  11. 1 required :index, Integer
  12. # @!attribute type
  13. # Always `file_path`.
  14. #
  15. # @return [Symbol, :file_path]
  16. 1 required :type, const: :file_path
  17. # @!attribute end_index
  18. #
  19. # @return [Integer, nil]
  20. 1 optional :end_index, Integer
  21. # @!attribute file_path
  22. #
  23. # @return [OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath, nil]
  24. 1 optional :file_path, -> { OpenAI::Beta::Threads::FilePathDeltaAnnotation::FilePath }
  25. # @!attribute start_index
  26. #
  27. # @return [Integer, nil]
  28. 1 optional :start_index, Integer
  29. # @!attribute text
  30. # The text in the message content that needs to be replaced.
  31. #
  32. # @return [String, nil]
  33. 1 optional :text, String
  34. # @!method initialize(index:, end_index: nil, file_path: nil, start_index: nil, text: nil, type: :file_path)
  35. # A URL for the file that's generated when the assistant used the
  36. # `code_interpreter` tool to generate a file.
  37. #
  38. # @param index [Integer] The index of the annotation in the text content part.
  39. #
  40. # @param end_index [Integer]
  41. #
  42. # @param file_path [OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation::FilePath]
  43. #
  44. # @param start_index [Integer]
  45. #
  46. # @param text [String] The text in the message content that needs to be replaced.
  47. #
  48. # @param type [Symbol, :file_path] Always `file_path`.
  49. # @see OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation#file_path
  50. 1 class FilePath < OpenAI::Internal::Type::BaseModel
  51. # @!attribute file_id
  52. # The ID of the file that was generated.
  53. #
  54. # @return [String, nil]
  55. 1 optional :file_id, String
  56. # @!method initialize(file_id: nil)
  57. # @param file_id [String] The ID of the file that was generated.
  58. end
  59. end
  60. end
  61. end
  62. end
  63. end

openai-ruby/lib/openai/models/beta/threads/image_file.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class ImageFile < OpenAI::Internal::Type::BaseModel
  7. # @!attribute file_id
  8. # The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
  9. # in the message content. Set `purpose="vision"` when uploading the File if you
  10. # need to later display the file content.
  11. #
  12. # @return [String]
  13. 1 required :file_id, String
  14. # @!attribute detail
  15. # Specifies the detail level of the image if specified by the user. `low` uses
  16. # fewer tokens, you can opt in to high resolution using `high`.
  17. #
  18. # @return [Symbol, OpenAI::Models::Beta::Threads::ImageFile::Detail, nil]
  19. 1 optional :detail, enum: -> { OpenAI::Beta::Threads::ImageFile::Detail }
  20. # @!method initialize(file_id:, detail: nil)
  21. # Some parameter documentations has been truncated, see
  22. # {OpenAI::Models::Beta::Threads::ImageFile} for more details.
  23. #
  24. # @param file_id [String] The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
  25. #
  26. # @param detail [Symbol, OpenAI::Models::Beta::Threads::ImageFile::Detail] Specifies the detail level of the image if specified by the user. `low` uses few
  27. # Specifies the detail level of the image if specified by the user. `low` uses
  28. # fewer tokens, you can opt in to high resolution using `high`.
  29. #
  30. # @see OpenAI::Models::Beta::Threads::ImageFile#detail
  31. 1 module Detail
  32. 1 extend OpenAI::Internal::Type::Enum
  33. 1 AUTO = :auto
  34. 1 LOW = :low
  35. 1 HIGH = :high
  36. # @!method self.values
  37. # @return [Array<Symbol>]
  38. end
  39. end
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/beta/threads/image_file_content_block.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class ImageFileContentBlock < OpenAI::Internal::Type::BaseModel
  7. # @!attribute image_file
  8. #
  9. # @return [OpenAI::Models::Beta::Threads::ImageFile]
  10. 1 required :image_file, -> { OpenAI::Beta::Threads::ImageFile }
  11. # @!attribute type
  12. # Always `image_file`.
  13. #
  14. # @return [Symbol, :image_file]
  15. 1 required :type, const: :image_file
  16. # @!method initialize(image_file:, type: :image_file)
  17. # References an image [File](https://platform.openai.com/docs/api-reference/files)
  18. # in the content of a message.
  19. #
  20. # @param image_file [OpenAI::Models::Beta::Threads::ImageFile]
  21. #
  22. # @param type [Symbol, :image_file] Always `image_file`.
  23. end
  24. end
  25. end
  26. end
  27. end

openai-ruby/lib/openai/models/beta/threads/image_file_delta.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class ImageFileDelta < OpenAI::Internal::Type::BaseModel
  7. # @!attribute detail
  8. # Specifies the detail level of the image if specified by the user. `low` uses
  9. # fewer tokens, you can opt in to high resolution using `high`.
  10. #
  11. # @return [Symbol, OpenAI::Models::Beta::Threads::ImageFileDelta::Detail, nil]
  12. 1 optional :detail, enum: -> { OpenAI::Beta::Threads::ImageFileDelta::Detail }
  13. # @!attribute file_id
  14. # The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
  15. # in the message content. Set `purpose="vision"` when uploading the File if you
  16. # need to later display the file content.
  17. #
  18. # @return [String, nil]
  19. 1 optional :file_id, String
  20. # @!method initialize(detail: nil, file_id: nil)
  21. # Some parameter documentations has been truncated, see
  22. # {OpenAI::Models::Beta::Threads::ImageFileDelta} for more details.
  23. #
  24. # @param detail [Symbol, OpenAI::Models::Beta::Threads::ImageFileDelta::Detail] Specifies the detail level of the image if specified by the user. `low` uses few
  25. #
  26. # @param file_id [String] The [File](https://platform.openai.com/docs/api-reference/files) ID of the image
  27. # Specifies the detail level of the image if specified by the user. `low` uses
  28. # fewer tokens, you can opt in to high resolution using `high`.
  29. #
  30. # @see OpenAI::Models::Beta::Threads::ImageFileDelta#detail
  31. 1 module Detail
  32. 1 extend OpenAI::Internal::Type::Enum
  33. 1 AUTO = :auto
  34. 1 LOW = :low
  35. 1 HIGH = :high
  36. # @!method self.values
  37. # @return [Array<Symbol>]
  38. end
  39. end
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/beta/threads/image_file_delta_block.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class ImageFileDeltaBlock < OpenAI::Internal::Type::BaseModel
  7. # @!attribute index
  8. # The index of the content part in the message.
  9. #
  10. # @return [Integer]
  11. 1 required :index, Integer
  12. # @!attribute type
  13. # Always `image_file`.
  14. #
  15. # @return [Symbol, :image_file]
  16. 1 required :type, const: :image_file
  17. # @!attribute image_file
  18. #
  19. # @return [OpenAI::Models::Beta::Threads::ImageFileDelta, nil]
  20. 1 optional :image_file, -> { OpenAI::Beta::Threads::ImageFileDelta }
  21. # @!method initialize(index:, image_file: nil, type: :image_file)
  22. # References an image [File](https://platform.openai.com/docs/api-reference/files)
  23. # in the content of a message.
  24. #
  25. # @param index [Integer] The index of the content part in the message.
  26. #
  27. # @param image_file [OpenAI::Models::Beta::Threads::ImageFileDelta]
  28. #
  29. # @param type [Symbol, :image_file] Always `image_file`.
  30. end
  31. end
  32. end
  33. end
  34. end

openai-ruby/lib/openai/models/beta/threads/image_url.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class ImageURL < OpenAI::Internal::Type::BaseModel
  7. # @!attribute url
  8. # The external URL of the image, must be a supported image types: jpeg, jpg, png,
  9. # gif, webp.
  10. #
  11. # @return [String]
  12. 1 required :url, String
  13. # @!attribute detail
  14. # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
  15. # to high resolution using `high`. Default value is `auto`
  16. #
  17. # @return [Symbol, OpenAI::Models::Beta::Threads::ImageURL::Detail, nil]
  18. 1 optional :detail, enum: -> { OpenAI::Beta::Threads::ImageURL::Detail }
  19. # @!method initialize(url:, detail: nil)
  20. # Some parameter documentations has been truncated, see
  21. # {OpenAI::Models::Beta::Threads::ImageURL} for more details.
  22. #
  23. # @param url [String] The external URL of the image, must be a supported image types: jpeg, jpg, png,
  24. #
  25. # @param detail [Symbol, OpenAI::Models::Beta::Threads::ImageURL::Detail] Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
  26. # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
  27. # to high resolution using `high`. Default value is `auto`
  28. #
  29. # @see OpenAI::Models::Beta::Threads::ImageURL#detail
  30. 1 module Detail
  31. 1 extend OpenAI::Internal::Type::Enum
  32. 1 AUTO = :auto
  33. 1 LOW = :low
  34. 1 HIGH = :high
  35. # @!method self.values
  36. # @return [Array<Symbol>]
  37. end
  38. end
  39. end
  40. end
  41. end
  42. end

openai-ruby/lib/openai/models/beta/threads/image_url_content_block.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class ImageURLContentBlock < OpenAI::Internal::Type::BaseModel
  7. # @!attribute image_url
  8. #
  9. # @return [OpenAI::Models::Beta::Threads::ImageURL]
  10. 1 required :image_url, -> { OpenAI::Beta::Threads::ImageURL }
  11. # @!attribute type
  12. # The type of the content part.
  13. #
  14. # @return [Symbol, :image_url]
  15. 1 required :type, const: :image_url
  16. # @!method initialize(image_url:, type: :image_url)
  17. # References an image URL in the content of a message.
  18. #
  19. # @param image_url [OpenAI::Models::Beta::Threads::ImageURL]
  20. #
  21. # @param type [Symbol, :image_url] The type of the content part.
  22. end
  23. end
  24. end
  25. end
  26. end

openai-ruby/lib/openai/models/beta/threads/image_url_delta.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class ImageURLDelta < OpenAI::Internal::Type::BaseModel
  7. # @!attribute detail
  8. # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
  9. # to high resolution using `high`.
  10. #
  11. # @return [Symbol, OpenAI::Models::Beta::Threads::ImageURLDelta::Detail, nil]
  12. 1 optional :detail, enum: -> { OpenAI::Beta::Threads::ImageURLDelta::Detail }
  13. # @!attribute url
  14. # The URL of the image, must be a supported image types: jpeg, jpg, png, gif,
  15. # webp.
  16. #
  17. # @return [String, nil]
  18. 1 optional :url, String
  19. # @!method initialize(detail: nil, url: nil)
  20. # Some parameter documentations has been truncated, see
  21. # {OpenAI::Models::Beta::Threads::ImageURLDelta} for more details.
  22. #
  23. # @param detail [Symbol, OpenAI::Models::Beta::Threads::ImageURLDelta::Detail] Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
  24. #
  25. # @param url [String] The URL of the image, must be a supported image types: jpeg, jpg, png, gif, webp
  26. # Specifies the detail level of the image. `low` uses fewer tokens, you can opt in
  27. # to high resolution using `high`.
  28. #
  29. # @see OpenAI::Models::Beta::Threads::ImageURLDelta#detail
  30. 1 module Detail
  31. 1 extend OpenAI::Internal::Type::Enum
  32. 1 AUTO = :auto
  33. 1 LOW = :low
  34. 1 HIGH = :high
  35. # @!method self.values
  36. # @return [Array<Symbol>]
  37. end
  38. end
  39. end
  40. end
  41. end
  42. end

openai-ruby/lib/openai/models/beta/threads/image_url_delta_block.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class ImageURLDeltaBlock < OpenAI::Internal::Type::BaseModel
  7. # @!attribute index
  8. # The index of the content part in the message.
  9. #
  10. # @return [Integer]
  11. 1 required :index, Integer
  12. # @!attribute type
  13. # Always `image_url`.
  14. #
  15. # @return [Symbol, :image_url]
  16. 1 required :type, const: :image_url
  17. # @!attribute image_url
  18. #
  19. # @return [OpenAI::Models::Beta::Threads::ImageURLDelta, nil]
  20. 1 optional :image_url, -> { OpenAI::Beta::Threads::ImageURLDelta }
  21. # @!method initialize(index:, image_url: nil, type: :image_url)
  22. # References an image URL in the content of a message.
  23. #
  24. # @param index [Integer] The index of the content part in the message.
  25. #
  26. # @param image_url [OpenAI::Models::Beta::Threads::ImageURLDelta]
  27. #
  28. # @param type [Symbol, :image_url] Always `image_url`.
  29. end
  30. end
  31. end
  32. end
  33. end

openai-ruby/lib/openai/models/beta/threads/message.rb

92.0% lines covered

100.0% branches covered

50 relevant lines. 46 lines covered and 4 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Messages#create
  7. 1 class Message < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # The identifier, which can be referenced in API endpoints.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute assistant_id
  14. # If applicable, the ID of the
  15. # [assistant](https://platform.openai.com/docs/api-reference/assistants) that
  16. # authored this message.
  17. #
  18. # @return [String, nil]
  19. 1 required :assistant_id, String, nil?: true
  20. # @!attribute attachments
  21. # A list of files attached to the message, and the tools they were added to.
  22. #
  23. # @return [Array<OpenAI::Models::Beta::Threads::Message::Attachment>, nil]
  24. 1 required :attachments,
  25. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::Threads::Message::Attachment] },
  26. nil?: true
  27. # @!attribute completed_at
  28. # The Unix timestamp (in seconds) for when the message was completed.
  29. #
  30. # @return [Integer, nil]
  31. 1 required :completed_at, Integer, nil?: true
  32. # @!attribute content
  33. # The content of the message in array of text and/or images.
  34. #
  35. # @return [Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlock, OpenAI::Models::Beta::Threads::RefusalContentBlock>]
  36. 1 required :content,
  37. -> {
  38. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::MessageContent]
  39. }
  40. # @!attribute created_at
  41. # The Unix timestamp (in seconds) for when the message was created.
  42. #
  43. # @return [Integer]
  44. 1 required :created_at, Integer
  45. # @!attribute incomplete_at
  46. # The Unix timestamp (in seconds) for when the message was marked as incomplete.
  47. #
  48. # @return [Integer, nil]
  49. 1 required :incomplete_at, Integer, nil?: true
  50. # @!attribute incomplete_details
  51. # On an incomplete message, details about why the message is incomplete.
  52. #
  53. # @return [OpenAI::Models::Beta::Threads::Message::IncompleteDetails, nil]
  54. 1 required :incomplete_details, -> { OpenAI::Beta::Threads::Message::IncompleteDetails }, nil?: true
  55. # @!attribute metadata
  56. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  57. # for storing additional information about the object in a structured format, and
  58. # querying for objects via API or the dashboard.
  59. #
  60. # Keys are strings with a maximum length of 64 characters. Values are strings with
  61. # a maximum length of 512 characters.
  62. #
  63. # @return [Hash{Symbol=>String}, nil]
  64. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  65. # @!attribute object
  66. # The object type, which is always `thread.message`.
  67. #
  68. # @return [Symbol, :"thread.message"]
  69. 1 required :object, const: :"thread.message"
  70. # @!attribute role
  71. # The entity that produced the message. One of `user` or `assistant`.
  72. #
  73. # @return [Symbol, OpenAI::Models::Beta::Threads::Message::Role]
  74. 1 required :role, enum: -> { OpenAI::Beta::Threads::Message::Role }
  75. # @!attribute run_id
  76. # The ID of the [run](https://platform.openai.com/docs/api-reference/runs)
  77. # associated with the creation of this message. Value is `null` when messages are
  78. # created manually using the create message or create thread endpoints.
  79. #
  80. # @return [String, nil]
  81. 1 required :run_id, String, nil?: true
  82. # @!attribute status
  83. # The status of the message, which can be either `in_progress`, `incomplete`, or
  84. # `completed`.
  85. #
  86. # @return [Symbol, OpenAI::Models::Beta::Threads::Message::Status]
  87. 1 required :status, enum: -> { OpenAI::Beta::Threads::Message::Status }
  88. # @!attribute thread_id
  89. # The [thread](https://platform.openai.com/docs/api-reference/threads) ID that
  90. # this message belongs to.
  91. #
  92. # @return [String]
  93. 1 required :thread_id, String
  94. # @!method initialize(id:, assistant_id:, attachments:, completed_at:, content:, created_at:, incomplete_at:, incomplete_details:, metadata:, role:, run_id:, status:, thread_id:, object: :"thread.message")
  95. # Some parameter documentations has been truncated, see
  96. # {OpenAI::Models::Beta::Threads::Message} for more details.
  97. #
  98. # Represents a message within a
  99. # [thread](https://platform.openai.com/docs/api-reference/threads).
  100. #
  101. # @param id [String] The identifier, which can be referenced in API endpoints.
  102. #
  103. # @param assistant_id [String, nil] If applicable, the ID of the [assistant](https://platform.openai.com/docs/api-re
  104. #
  105. # @param attachments [Array<OpenAI::Models::Beta::Threads::Message::Attachment>, nil] A list of files attached to the message, and the tools they were added to.
  106. #
  107. # @param completed_at [Integer, nil] The Unix timestamp (in seconds) for when the message was completed.
  108. #
  109. # @param content [Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlock, OpenAI::Models::Beta::Threads::RefusalContentBlock>] The content of the message in array of text and/or images.
  110. #
  111. # @param created_at [Integer] The Unix timestamp (in seconds) for when the message was created.
  112. #
  113. # @param incomplete_at [Integer, nil] The Unix timestamp (in seconds) for when the message was marked as incomplete.
  114. #
  115. # @param incomplete_details [OpenAI::Models::Beta::Threads::Message::IncompleteDetails, nil] On an incomplete message, details about why the message is incomplete.
  116. #
  117. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  118. #
  119. # @param role [Symbol, OpenAI::Models::Beta::Threads::Message::Role] The entity that produced the message. One of `user` or `assistant`.
  120. #
  121. # @param run_id [String, nil] The ID of the [run](https://platform.openai.com/docs/api-reference/runs) associa
  122. #
  123. # @param status [Symbol, OpenAI::Models::Beta::Threads::Message::Status] The status of the message, which can be either `in_progress`, `incomplete`, or `
  124. #
  125. # @param thread_id [String] The [thread](https://platform.openai.com/docs/api-reference/threads) ID that thi
  126. #
  127. # @param object [Symbol, :"thread.message"] The object type, which is always `thread.message`.
  128. 1 class Attachment < OpenAI::Internal::Type::BaseModel
  129. # @!attribute file_id
  130. # The ID of the file to attach to the message.
  131. #
  132. # @return [String, nil]
  133. 1 optional :file_id, String
  134. # @!attribute tools
  135. # The tools to add this file to.
  136. #
  137. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly>, nil]
  138. 1 optional :tools,
  139. -> {
  140. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::Message::Attachment::Tool]
  141. }
  142. # @!method initialize(file_id: nil, tools: nil)
  143. # @param file_id [String] The ID of the file to attach to the message.
  144. #
  145. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly>] The tools to add this file to.
  146. 1 module Tool
  147. 1 extend OpenAI::Internal::Type::Union
  148. 1 variant -> { OpenAI::Beta::CodeInterpreterTool }
  149. 1 variant -> {
  150. OpenAI::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly
  151. }
  152. 1 class AssistantToolsFileSearchTypeOnly < OpenAI::Internal::Type::BaseModel
  153. # @!attribute type
  154. # The type of tool being defined: `file_search`
  155. #
  156. # @return [Symbol, :file_search]
  157. 1 required :type, const: :file_search
  158. # @!method initialize(type: :file_search)
  159. # @param type [Symbol, :file_search] The type of tool being defined: `file_search`
  160. end
  161. # @!method self.variants
  162. # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::Message::Attachment::Tool::AssistantToolsFileSearchTypeOnly)]
  163. end
  164. end
  165. # @see OpenAI::Models::Beta::Threads::Message#incomplete_details
  166. 1 class IncompleteDetails < OpenAI::Internal::Type::BaseModel
  167. # @!attribute reason
  168. # The reason the message is incomplete.
  169. #
  170. # @return [Symbol, OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason]
  171. 1 required :reason, enum: -> { OpenAI::Beta::Threads::Message::IncompleteDetails::Reason }
  172. # @!method initialize(reason:)
  173. # On an incomplete message, details about why the message is incomplete.
  174. #
  175. # @param reason [Symbol, OpenAI::Models::Beta::Threads::Message::IncompleteDetails::Reason] The reason the message is incomplete.
  176. # The reason the message is incomplete.
  177. #
  178. # @see OpenAI::Models::Beta::Threads::Message::IncompleteDetails#reason
  179. 1 module Reason
  180. 1 extend OpenAI::Internal::Type::Enum
  181. 1 CONTENT_FILTER = :content_filter
  182. 1 MAX_TOKENS = :max_tokens
  183. 1 RUN_CANCELLED = :run_cancelled
  184. 1 RUN_EXPIRED = :run_expired
  185. 1 RUN_FAILED = :run_failed
  186. # @!method self.values
  187. # @return [Array<Symbol>]
  188. end
  189. end
  190. # The entity that produced the message. One of `user` or `assistant`.
  191. #
  192. # @see OpenAI::Models::Beta::Threads::Message#role
  193. 1 module Role
  194. 1 extend OpenAI::Internal::Type::Enum
  195. 1 USER = :user
  196. 1 ASSISTANT = :assistant
  197. # @!method self.values
  198. # @return [Array<Symbol>]
  199. end
  200. # The status of the message, which can be either `in_progress`, `incomplete`, or
  201. # `completed`.
  202. #
  203. # @see OpenAI::Models::Beta::Threads::Message#status
  204. 1 module Status
  205. 1 extend OpenAI::Internal::Type::Enum
  206. 1 IN_PROGRESS = :in_progress
  207. 1 INCOMPLETE = :incomplete
  208. 1 COMPLETED = :completed
  209. # @!method self.values
  210. # @return [Array<Symbol>]
  211. end
  212. end
  213. end
  214. end
  215. end
  216. end

openai-ruby/lib/openai/models/beta/threads/message_content.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # References an image [File](https://platform.openai.com/docs/api-reference/files)
  7. # in the content of a message.
  8. 1 module MessageContent
  9. 1 extend OpenAI::Internal::Type::Union
  10. 1 discriminator :type
  11. # References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message.
  12. 1 variant :image_file, -> { OpenAI::Beta::Threads::ImageFileContentBlock }
  13. # References an image URL in the content of a message.
  14. 1 variant :image_url, -> { OpenAI::Beta::Threads::ImageURLContentBlock }
  15. # The text content that is part of a message.
  16. 1 variant :text, -> { OpenAI::Beta::Threads::TextContentBlock }
  17. # The refusal content generated by the assistant.
  18. 1 variant :refusal, -> { OpenAI::Beta::Threads::RefusalContentBlock }
  19. # @!method self.variants
  20. # @return [Array(OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlock, OpenAI::Models::Beta::Threads::RefusalContentBlock)]
  21. end
  22. end
  23. end
  24. end
  25. end

openai-ruby/lib/openai/models/beta/threads/message_content_delta.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # References an image [File](https://platform.openai.com/docs/api-reference/files)
  7. # in the content of a message.
  8. 1 module MessageContentDelta
  9. 1 extend OpenAI::Internal::Type::Union
  10. 1 discriminator :type
  11. # References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message.
  12. 1 variant :image_file, -> { OpenAI::Beta::Threads::ImageFileDeltaBlock }
  13. # The text content that is part of a message.
  14. 1 variant :text, -> { OpenAI::Beta::Threads::TextDeltaBlock }
  15. # The refusal content that is part of a message.
  16. 1 variant :refusal, -> { OpenAI::Beta::Threads::RefusalDeltaBlock }
  17. # References an image URL in the content of a message.
  18. 1 variant :image_url, -> { OpenAI::Beta::Threads::ImageURLDeltaBlock }
  19. # @!method self.variants
  20. # @return [Array(OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock)]
  21. end
  22. end
  23. end
  24. end
  25. end

openai-ruby/lib/openai/models/beta/threads/message_content_part_param.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # References an image [File](https://platform.openai.com/docs/api-reference/files)
  7. # in the content of a message.
  8. 1 module MessageContentPartParam
  9. 1 extend OpenAI::Internal::Type::Union
  10. 1 discriminator :type
  11. # References an image [File](https://platform.openai.com/docs/api-reference/files) in the content of a message.
  12. 1 variant :image_file, -> { OpenAI::Beta::Threads::ImageFileContentBlock }
  13. # References an image URL in the content of a message.
  14. 1 variant :image_url, -> { OpenAI::Beta::Threads::ImageURLContentBlock }
  15. # The text content that is part of a message.
  16. 1 variant :text, -> { OpenAI::Beta::Threads::TextContentBlockParam }
  17. # @!method self.variants
  18. # @return [Array(OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam)]
  19. end
  20. end
  21. end
  22. end
  23. end

openai-ruby/lib/openai/models/beta/threads/message_create_params.rb

90.91% lines covered

100.0% branches covered

33 relevant lines. 30 lines covered and 3 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Messages#create
  7. 1 class MessageCreateParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute content
  11. # The text contents of the message.
  12. #
  13. # @return [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>]
  14. 1 required :content, union: -> { OpenAI::Beta::Threads::MessageCreateParams::Content }
  15. # @!attribute role
  16. # The role of the entity that is creating the message. Allowed values include:
  17. #
  18. # - `user`: Indicates the message is sent by an actual user and should be used in
  19. # most cases to represent user-generated messages.
  20. # - `assistant`: Indicates the message is generated by the assistant. Use this
  21. # value to insert messages from the assistant into the conversation.
  22. #
  23. # @return [Symbol, OpenAI::Models::Beta::Threads::MessageCreateParams::Role]
  24. 1 required :role, enum: -> { OpenAI::Beta::Threads::MessageCreateParams::Role }
  25. # @!attribute attachments
  26. # A list of files attached to the message, and the tools they should be added to.
  27. #
  28. # @return [Array<OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment>, nil]
  29. 1 optional :attachments,
  30. -> {
  31. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::Threads::MessageCreateParams::Attachment]
  32. },
  33. nil?: true
  34. # @!attribute metadata
  35. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  36. # for storing additional information about the object in a structured format, and
  37. # querying for objects via API or the dashboard.
  38. #
  39. # Keys are strings with a maximum length of 64 characters. Values are strings with
  40. # a maximum length of 512 characters.
  41. #
  42. # @return [Hash{Symbol=>String}, nil]
  43. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  44. # @!method initialize(content:, role:, attachments: nil, metadata: nil, request_options: {})
  45. # Some parameter documentations has been truncated, see
  46. # {OpenAI::Models::Beta::Threads::MessageCreateParams} for more details.
  47. #
  48. # @param content [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>] The text contents of the message.
  49. #
  50. # @param role [Symbol, OpenAI::Models::Beta::Threads::MessageCreateParams::Role] The role of the entity that is creating the message. Allowed values include:
  51. #
  52. # @param attachments [Array<OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment>, nil] A list of files attached to the message, and the tools they should be added to.
  53. #
  54. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  55. #
  56. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  57. # The text contents of the message.
  58. 1 module Content
  59. 1 extend OpenAI::Internal::Type::Union
  60. # The text contents of the message.
  61. 1 variant String
  62. # An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models).
  63. 1 variant -> { OpenAI::Models::Beta::Threads::MessageCreateParams::Content::MessageContentPartParamArray }
  64. # @!method self.variants
  65. # @return [Array(String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>)]
  66. # @type [OpenAI::Internal::Type::Converter]
  67. MessageContentPartParamArray =
  68. 1 OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Beta::Threads::MessageContentPartParam }]
  69. end
  70. # The role of the entity that is creating the message. Allowed values include:
  71. #
  72. # - `user`: Indicates the message is sent by an actual user and should be used in
  73. # most cases to represent user-generated messages.
  74. # - `assistant`: Indicates the message is generated by the assistant. Use this
  75. # value to insert messages from the assistant into the conversation.
  76. 1 module Role
  77. 1 extend OpenAI::Internal::Type::Enum
  78. 1 USER = :user
  79. 1 ASSISTANT = :assistant
  80. # @!method self.values
  81. # @return [Array<Symbol>]
  82. end
  83. 1 class Attachment < OpenAI::Internal::Type::BaseModel
  84. # @!attribute file_id
  85. # The ID of the file to attach to the message.
  86. #
  87. # @return [String, nil]
  88. 1 optional :file_id, String
  89. # @!attribute tools
  90. # The tools to add this file to.
  91. #
  92. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch>, nil]
  93. 1 optional :tools,
  94. -> {
  95. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::MessageCreateParams::Attachment::Tool]
  96. }
  97. # @!method initialize(file_id: nil, tools: nil)
  98. # @param file_id [String] The ID of the file to attach to the message.
  99. #
  100. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch>] The tools to add this file to.
  101. 1 module Tool
  102. 1 extend OpenAI::Internal::Type::Union
  103. 1 discriminator :type
  104. 1 variant :code_interpreter, -> { OpenAI::Beta::CodeInterpreterTool }
  105. 1 variant :file_search,
  106. -> {
  107. OpenAI::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch
  108. }
  109. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  110. # @!attribute type
  111. # The type of tool being defined: `file_search`
  112. #
  113. # @return [Symbol, :file_search]
  114. 1 required :type, const: :file_search
  115. # @!method initialize(type: :file_search)
  116. # @param type [Symbol, :file_search] The type of tool being defined: `file_search`
  117. end
  118. # @!method self.variants
  119. # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment::Tool::FileSearch)]
  120. end
  121. end
  122. end
  123. end
  124. end
  125. end
  126. end

openai-ruby/lib/openai/models/beta/threads/message_delete_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Messages#delete
  7. 1 class MessageDeleteParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute thread_id
  11. #
  12. # @return [String]
  13. 1 required :thread_id, String
  14. # @!method initialize(thread_id:, request_options: {})
  15. # @param thread_id [String]
  16. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  17. end
  18. end
  19. end
  20. end
  21. end

openai-ruby/lib/openai/models/beta/threads/message_deleted.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Messages#delete
  7. 1 class MessageDeleted < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute deleted
  13. #
  14. # @return [Boolean]
  15. 1 required :deleted, OpenAI::Internal::Type::Boolean
  16. # @!attribute object
  17. #
  18. # @return [Symbol, :"thread.message.deleted"]
  19. 1 required :object, const: :"thread.message.deleted"
  20. # @!method initialize(id:, deleted:, object: :"thread.message.deleted")
  21. # @param id [String]
  22. # @param deleted [Boolean]
  23. # @param object [Symbol, :"thread.message.deleted"]
  24. end
  25. end
  26. end
  27. end
  28. end

openai-ruby/lib/openai/models/beta/threads/message_delta.rb

91.67% lines covered

100.0% branches covered

12 relevant lines. 11 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class MessageDelta < OpenAI::Internal::Type::BaseModel
  7. # @!attribute content
  8. # The content of the message in array of text and/or images.
  9. #
  10. # @return [Array<OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock>, nil]
  11. 1 optional :content,
  12. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::MessageContentDelta] }
  13. # @!attribute role
  14. # The entity that produced the message. One of `user` or `assistant`.
  15. #
  16. # @return [Symbol, OpenAI::Models::Beta::Threads::MessageDelta::Role, nil]
  17. 1 optional :role, enum: -> { OpenAI::Beta::Threads::MessageDelta::Role }
  18. # @!method initialize(content: nil, role: nil)
  19. # The delta containing the fields that have changed on the Message.
  20. #
  21. # @param content [Array<OpenAI::Models::Beta::Threads::ImageFileDeltaBlock, OpenAI::Models::Beta::Threads::TextDeltaBlock, OpenAI::Models::Beta::Threads::RefusalDeltaBlock, OpenAI::Models::Beta::Threads::ImageURLDeltaBlock>] The content of the message in array of text and/or images.
  22. #
  23. # @param role [Symbol, OpenAI::Models::Beta::Threads::MessageDelta::Role] The entity that produced the message. One of `user` or `assistant`.
  24. # The entity that produced the message. One of `user` or `assistant`.
  25. #
  26. # @see OpenAI::Models::Beta::Threads::MessageDelta#role
  27. 1 module Role
  28. 1 extend OpenAI::Internal::Type::Enum
  29. 1 USER = :user
  30. 1 ASSISTANT = :assistant
  31. # @!method self.values
  32. # @return [Array<Symbol>]
  33. end
  34. end
  35. end
  36. end
  37. end
  38. end

openai-ruby/lib/openai/models/beta/threads/message_delta_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class MessageDeltaEvent < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The identifier of the message, which can be referenced in API endpoints.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute delta
  13. # The delta containing the fields that have changed on the Message.
  14. #
  15. # @return [OpenAI::Models::Beta::Threads::MessageDelta]
  16. 1 required :delta, -> { OpenAI::Beta::Threads::MessageDelta }
  17. # @!attribute object
  18. # The object type, which is always `thread.message.delta`.
  19. #
  20. # @return [Symbol, :"thread.message.delta"]
  21. 1 required :object, const: :"thread.message.delta"
  22. # @!method initialize(id:, delta:, object: :"thread.message.delta")
  23. # Represents a message delta i.e. any changed fields on a message during
  24. # streaming.
  25. #
  26. # @param id [String] The identifier of the message, which can be referenced in API endpoints.
  27. #
  28. # @param delta [OpenAI::Models::Beta::Threads::MessageDelta] The delta containing the fields that have changed on the Message.
  29. #
  30. # @param object [Symbol, :"thread.message.delta"] The object type, which is always `thread.message.delta`.
  31. end
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/beta/threads/message_list_params.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Messages#list
  7. 1 class MessageListParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute after
  11. # A cursor for use in pagination. `after` is an object ID that defines your place
  12. # in the list. For instance, if you make a list request and receive 100 objects,
  13. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  14. # fetch the next page of the list.
  15. #
  16. # @return [String, nil]
  17. 1 optional :after, String
  18. # @!attribute before
  19. # A cursor for use in pagination. `before` is an object ID that defines your place
  20. # in the list. For instance, if you make a list request and receive 100 objects,
  21. # starting with obj_foo, your subsequent call can include before=obj_foo in order
  22. # to fetch the previous page of the list.
  23. #
  24. # @return [String, nil]
  25. 1 optional :before, String
  26. # @!attribute limit
  27. # A limit on the number of objects to be returned. Limit can range between 1 and
  28. # 100, and the default is 20.
  29. #
  30. # @return [Integer, nil]
  31. 1 optional :limit, Integer
  32. # @!attribute order
  33. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  34. # order and `desc` for descending order.
  35. #
  36. # @return [Symbol, OpenAI::Models::Beta::Threads::MessageListParams::Order, nil]
  37. 1 optional :order, enum: -> { OpenAI::Beta::Threads::MessageListParams::Order }
  38. # @!attribute run_id
  39. # Filter messages by the run ID that generated them.
  40. #
  41. # @return [String, nil]
  42. 1 optional :run_id, String
  43. # @!method initialize(after: nil, before: nil, limit: nil, order: nil, run_id: nil, request_options: {})
  44. # Some parameter documentations has been truncated, see
  45. # {OpenAI::Models::Beta::Threads::MessageListParams} for more details.
  46. #
  47. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  48. #
  49. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  50. #
  51. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  52. #
  53. # @param order [Symbol, OpenAI::Models::Beta::Threads::MessageListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  54. #
  55. # @param run_id [String] Filter messages by the run ID that generated them.
  56. #
  57. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  58. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  59. # order and `desc` for descending order.
  60. 1 module Order
  61. 1 extend OpenAI::Internal::Type::Enum
  62. 1 ASC = :asc
  63. 1 DESC = :desc
  64. # @!method self.values
  65. # @return [Array<Symbol>]
  66. end
  67. end
  68. end
  69. end
  70. end
  71. end

openai-ruby/lib/openai/models/beta/threads/message_retrieve_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Messages#retrieve
  7. 1 class MessageRetrieveParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute thread_id
  11. #
  12. # @return [String]
  13. 1 required :thread_id, String
  14. # @!method initialize(thread_id:, request_options: {})
  15. # @param thread_id [String]
  16. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  17. end
  18. end
  19. end
  20. end
  21. end

openai-ruby/lib/openai/models/beta/threads/message_update_params.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Messages#update
  7. 1 class MessageUpdateParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute thread_id
  11. #
  12. # @return [String]
  13. 1 required :thread_id, String
  14. # @!attribute metadata
  15. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  16. # for storing additional information about the object in a structured format, and
  17. # querying for objects via API or the dashboard.
  18. #
  19. # Keys are strings with a maximum length of 64 characters. Values are strings with
  20. # a maximum length of 512 characters.
  21. #
  22. # @return [Hash{Symbol=>String}, nil]
  23. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  24. # @!method initialize(thread_id:, metadata: nil, request_options: {})
  25. # Some parameter documentations has been truncated, see
  26. # {OpenAI::Models::Beta::Threads::MessageUpdateParams} for more details.
  27. #
  28. # @param thread_id [String]
  29. #
  30. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  31. #
  32. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  33. end
  34. end
  35. end
  36. end
  37. end

openai-ruby/lib/openai/models/beta/threads/refusal_content_block.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class RefusalContentBlock < OpenAI::Internal::Type::BaseModel
  7. # @!attribute refusal
  8. #
  9. # @return [String]
  10. 1 required :refusal, String
  11. # @!attribute type
  12. # Always `refusal`.
  13. #
  14. # @return [Symbol, :refusal]
  15. 1 required :type, const: :refusal
  16. # @!method initialize(refusal:, type: :refusal)
  17. # The refusal content generated by the assistant.
  18. #
  19. # @param refusal [String]
  20. #
  21. # @param type [Symbol, :refusal] Always `refusal`.
  22. end
  23. end
  24. end
  25. end
  26. end

openai-ruby/lib/openai/models/beta/threads/refusal_delta_block.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class RefusalDeltaBlock < OpenAI::Internal::Type::BaseModel
  7. # @!attribute index
  8. # The index of the refusal part in the message.
  9. #
  10. # @return [Integer]
  11. 1 required :index, Integer
  12. # @!attribute type
  13. # Always `refusal`.
  14. #
  15. # @return [Symbol, :refusal]
  16. 1 required :type, const: :refusal
  17. # @!attribute refusal
  18. #
  19. # @return [String, nil]
  20. 1 optional :refusal, String
  21. # @!method initialize(index:, refusal: nil, type: :refusal)
  22. # The refusal content that is part of a message.
  23. #
  24. # @param index [Integer] The index of the refusal part in the message.
  25. #
  26. # @param refusal [String]
  27. #
  28. # @param type [Symbol, :refusal] Always `refusal`.
  29. end
  30. end
  31. end
  32. end
  33. end

openai-ruby/lib/openai/models/beta/threads/required_action_function_tool_call.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class RequiredActionFunctionToolCall < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The ID of the tool call. This ID must be referenced when you submit the tool
  9. # outputs in using the
  10. # [Submit tool outputs to run](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
  11. # endpoint.
  12. #
  13. # @return [String]
  14. 1 required :id, String
  15. # @!attribute function
  16. # The function definition.
  17. #
  18. # @return [OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function]
  19. 1 required :function, -> { OpenAI::Beta::Threads::RequiredActionFunctionToolCall::Function }
  20. # @!attribute type
  21. # The type of tool call the output is required for. For now, this is always
  22. # `function`.
  23. #
  24. # @return [Symbol, :function]
  25. 1 required :type, const: :function
  26. # @!method initialize(id:, function:, type: :function)
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall} for more
  29. # details.
  30. #
  31. # Tool call objects
  32. #
  33. # @param id [String] The ID of the tool call. This ID must be referenced when you submit the tool out
  34. #
  35. # @param function [OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall::Function] The function definition.
  36. #
  37. # @param type [Symbol, :function] The type of tool call the output is required for. For now, this is always `funct
  38. # @see OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall#function
  39. 1 class Function < OpenAI::Internal::Type::BaseModel
  40. # @!attribute arguments
  41. # The arguments that the model expects you to pass to the function.
  42. #
  43. # @return [String]
  44. 1 required :arguments, String
  45. # @!attribute name
  46. # The name of the function.
  47. #
  48. # @return [String]
  49. 1 required :name, String
  50. # @!method initialize(arguments:, name:)
  51. # The function definition.
  52. #
  53. # @param arguments [String] The arguments that the model expects you to pass to the function.
  54. #
  55. # @param name [String] The name of the function.
  56. end
  57. end
  58. end
  59. end
  60. end
  61. end

openai-ruby/lib/openai/models/beta/threads/run.rb

96.88% lines covered

100.0% branches covered

64 relevant lines. 62 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Runs#create
  7. #
  8. # @see OpenAI::Resources::Beta::Threads::Runs#create_stream_raw
  9. 1 class Run < OpenAI::Internal::Type::BaseModel
  10. # @!attribute id
  11. # The identifier, which can be referenced in API endpoints.
  12. #
  13. # @return [String]
  14. 1 required :id, String
  15. # @!attribute assistant_id
  16. # The ID of the
  17. # [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
  18. # execution of this run.
  19. #
  20. # @return [String]
  21. 1 required :assistant_id, String
  22. # @!attribute cancelled_at
  23. # The Unix timestamp (in seconds) for when the run was cancelled.
  24. #
  25. # @return [Integer, nil]
  26. 1 required :cancelled_at, Integer, nil?: true
  27. # @!attribute completed_at
  28. # The Unix timestamp (in seconds) for when the run was completed.
  29. #
  30. # @return [Integer, nil]
  31. 1 required :completed_at, Integer, nil?: true
  32. # @!attribute created_at
  33. # The Unix timestamp (in seconds) for when the run was created.
  34. #
  35. # @return [Integer]
  36. 1 required :created_at, Integer
  37. # @!attribute expires_at
  38. # The Unix timestamp (in seconds) for when the run will expire.
  39. #
  40. # @return [Integer, nil]
  41. 1 required :expires_at, Integer, nil?: true
  42. # @!attribute failed_at
  43. # The Unix timestamp (in seconds) for when the run failed.
  44. #
  45. # @return [Integer, nil]
  46. 1 required :failed_at, Integer, nil?: true
  47. # @!attribute incomplete_details
  48. # Details on why the run is incomplete. Will be `null` if the run is not
  49. # incomplete.
  50. #
  51. # @return [OpenAI::Models::Beta::Threads::Run::IncompleteDetails, nil]
  52. 1 required :incomplete_details, -> { OpenAI::Beta::Threads::Run::IncompleteDetails }, nil?: true
  53. # @!attribute instructions
  54. # The instructions that the
  55. # [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
  56. # this run.
  57. #
  58. # @return [String]
  59. 1 required :instructions, String
  60. # @!attribute last_error
  61. # The last error associated with this run. Will be `null` if there are no errors.
  62. #
  63. # @return [OpenAI::Models::Beta::Threads::Run::LastError, nil]
  64. 1 required :last_error, -> { OpenAI::Beta::Threads::Run::LastError }, nil?: true
  65. # @!attribute max_completion_tokens
  66. # The maximum number of completion tokens specified to have been used over the
  67. # course of the run.
  68. #
  69. # @return [Integer, nil]
  70. 1 required :max_completion_tokens, Integer, nil?: true
  71. # @!attribute max_prompt_tokens
  72. # The maximum number of prompt tokens specified to have been used over the course
  73. # of the run.
  74. #
  75. # @return [Integer, nil]
  76. 1 required :max_prompt_tokens, Integer, nil?: true
  77. # @!attribute metadata
  78. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  79. # for storing additional information about the object in a structured format, and
  80. # querying for objects via API or the dashboard.
  81. #
  82. # Keys are strings with a maximum length of 64 characters. Values are strings with
  83. # a maximum length of 512 characters.
  84. #
  85. # @return [Hash{Symbol=>String}, nil]
  86. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  87. # @!attribute model
  88. # The model that the
  89. # [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
  90. # this run.
  91. #
  92. # @return [String]
  93. 1 required :model, String
  94. # @!attribute object
  95. # The object type, which is always `thread.run`.
  96. #
  97. # @return [Symbol, :"thread.run"]
  98. 1 required :object, const: :"thread.run"
  99. # @!attribute parallel_tool_calls
  100. # Whether to enable
  101. # [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
  102. # during tool use.
  103. #
  104. # @return [Boolean]
  105. 1 required :parallel_tool_calls, OpenAI::Internal::Type::Boolean
  106. # @!attribute required_action
  107. # Details on the action required to continue the run. Will be `null` if no action
  108. # is required.
  109. #
  110. # @return [OpenAI::Models::Beta::Threads::Run::RequiredAction, nil]
  111. 1 required :required_action, -> { OpenAI::Beta::Threads::Run::RequiredAction }, nil?: true
  112. # @!attribute response_format
  113. # Specifies the format that the model must output. Compatible with
  114. # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  115. # [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  116. # and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  117. #
  118. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  119. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  120. # in the
  121. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  122. #
  123. # Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  124. # message the model generates is valid JSON.
  125. #
  126. # **Important:** when using JSON mode, you **must** also instruct the model to
  127. # produce JSON yourself via a system or user message. Without this, the model may
  128. # generate an unending stream of whitespace until the generation reaches the token
  129. # limit, resulting in a long-running and seemingly "stuck" request. Also note that
  130. # the message content may be partially cut off if `finish_reason="length"`, which
  131. # indicates the generation exceeded `max_tokens` or the conversation exceeded the
  132. # max context length.
  133. #
  134. # @return [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil]
  135. 1 required :response_format, union: -> { OpenAI::Beta::AssistantResponseFormatOption }, nil?: true
  136. # @!attribute started_at
  137. # The Unix timestamp (in seconds) for when the run was started.
  138. #
  139. # @return [Integer, nil]
  140. 1 required :started_at, Integer, nil?: true
  141. # @!attribute status
  142. # The status of the run, which can be either `queued`, `in_progress`,
  143. # `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`,
  144. # `incomplete`, or `expired`.
  145. #
  146. # @return [Symbol, OpenAI::Models::Beta::Threads::RunStatus]
  147. 1 required :status, enum: -> { OpenAI::Beta::Threads::RunStatus }
  148. # @!attribute thread_id
  149. # The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
  150. # that was executed on as a part of this run.
  151. #
  152. # @return [String]
  153. 1 required :thread_id, String
  154. # @!attribute tool_choice
  155. # Controls which (if any) tool is called by the model. `none` means the model will
  156. # not call any tools and instead generates a message. `auto` is the default value
  157. # and means the model can pick between generating a message or calling one or more
  158. # tools. `required` means the model must call one or more tools before responding
  159. # to the user. Specifying a particular tool like `{"type": "file_search"}` or
  160. # `{"type": "function", "function": {"name": "my_function"}}` forces the model to
  161. # call that tool.
  162. #
  163. # @return [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil]
  164. 1 required :tool_choice, union: -> { OpenAI::Beta::AssistantToolChoiceOption }, nil?: true
  165. # @!attribute tools
  166. # The list of tools that the
  167. # [assistant](https://platform.openai.com/docs/api-reference/assistants) used for
  168. # this run.
  169. #
  170. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>]
  171. 1 required :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::AssistantTool] }
  172. # @!attribute truncation_strategy
  173. # Controls for how a thread will be truncated prior to the run. Use this to
  174. # control the intial context window of the run.
  175. #
  176. # @return [OpenAI::Models::Beta::Threads::Run::TruncationStrategy, nil]
  177. 1 required :truncation_strategy, -> { OpenAI::Beta::Threads::Run::TruncationStrategy }, nil?: true
  178. # @!attribute usage
  179. # Usage statistics related to the run. This value will be `null` if the run is not
  180. # in a terminal state (i.e. `in_progress`, `queued`, etc.).
  181. #
  182. # @return [OpenAI::Models::Beta::Threads::Run::Usage, nil]
  183. 1 required :usage, -> { OpenAI::Beta::Threads::Run::Usage }, nil?: true
  184. # @!attribute temperature
  185. # The sampling temperature used for this run. If not set, defaults to 1.
  186. #
  187. # @return [Float, nil]
  188. 1 optional :temperature, Float, nil?: true
  189. # @!attribute top_p
  190. # The nucleus sampling value used for this run. If not set, defaults to 1.
  191. #
  192. # @return [Float, nil]
  193. 1 optional :top_p, Float, nil?: true
  194. # @!method initialize(id:, assistant_id:, cancelled_at:, completed_at:, created_at:, expires_at:, failed_at:, incomplete_details:, instructions:, last_error:, max_completion_tokens:, max_prompt_tokens:, metadata:, model:, parallel_tool_calls:, required_action:, response_format:, started_at:, status:, thread_id:, tool_choice:, tools:, truncation_strategy:, usage:, temperature: nil, top_p: nil, object: :"thread.run")
  195. # Some parameter documentations has been truncated, see
  196. # {OpenAI::Models::Beta::Threads::Run} for more details.
  197. #
  198. # Represents an execution run on a
  199. # [thread](https://platform.openai.com/docs/api-reference/threads).
  200. #
  201. # @param id [String] The identifier, which can be referenced in API endpoints.
  202. #
  203. # @param assistant_id [String] The ID of the [assistant](https://platform.openai.com/docs/api-reference/assista
  204. #
  205. # @param cancelled_at [Integer, nil] The Unix timestamp (in seconds) for when the run was cancelled.
  206. #
  207. # @param completed_at [Integer, nil] The Unix timestamp (in seconds) for when the run was completed.
  208. #
  209. # @param created_at [Integer] The Unix timestamp (in seconds) for when the run was created.
  210. #
  211. # @param expires_at [Integer, nil] The Unix timestamp (in seconds) for when the run will expire.
  212. #
  213. # @param failed_at [Integer, nil] The Unix timestamp (in seconds) for when the run failed.
  214. #
  215. # @param incomplete_details [OpenAI::Models::Beta::Threads::Run::IncompleteDetails, nil] Details on why the run is incomplete. Will be `null` if the run is not incomplet
  216. #
  217. # @param instructions [String] The instructions that the [assistant](https://platform.openai.com/docs/api-refer
  218. #
  219. # @param last_error [OpenAI::Models::Beta::Threads::Run::LastError, nil] The last error associated with this run. Will be `null` if there are no errors.
  220. #
  221. # @param max_completion_tokens [Integer, nil] The maximum number of completion tokens specified to have been used over the cou
  222. #
  223. # @param max_prompt_tokens [Integer, nil] The maximum number of prompt tokens specified to have been used over the course
  224. #
  225. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  226. #
  227. # @param model [String] The model that the [assistant](https://platform.openai.com/docs/api-reference/as
  228. #
  229. # @param parallel_tool_calls [Boolean] Whether to enable [parallel function calling](https://platform.openai.com/docs/g
  230. #
  231. # @param required_action [OpenAI::Models::Beta::Threads::Run::RequiredAction, nil] Details on the action required to continue the run. Will be `null` if no action
  232. #
  233. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  234. #
  235. # @param started_at [Integer, nil] The Unix timestamp (in seconds) for when the run was started.
  236. #
  237. # @param status [Symbol, OpenAI::Models::Beta::Threads::RunStatus] The status of the run, which can be either `queued`, `in_progress`, `requires_ac
  238. #
  239. # @param thread_id [String] The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) t
  240. #
  241. # @param tool_choice [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil] Controls which (if any) tool is called by the model.
  242. #
  243. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>] The list of tools that the [assistant](https://platform.openai.com/docs/api-refe
  244. #
  245. # @param truncation_strategy [OpenAI::Models::Beta::Threads::Run::TruncationStrategy, nil] Controls for how a thread will be truncated prior to the run. Use this to contro
  246. #
  247. # @param usage [OpenAI::Models::Beta::Threads::Run::Usage, nil] Usage statistics related to the run. This value will be `null` if the run is not
  248. #
  249. # @param temperature [Float, nil] The sampling temperature used for this run. If not set, defaults to 1.
  250. #
  251. # @param top_p [Float, nil] The nucleus sampling value used for this run. If not set, defaults to 1.
  252. #
  253. # @param object [Symbol, :"thread.run"] The object type, which is always `thread.run`.
  254. # @see OpenAI::Models::Beta::Threads::Run#incomplete_details
  255. 1 class IncompleteDetails < OpenAI::Internal::Type::BaseModel
  256. # @!attribute reason
  257. # The reason why the run is incomplete. This will point to which specific token
  258. # limit was reached over the course of the run.
  259. #
  260. # @return [Symbol, OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason, nil]
  261. 1 optional :reason, enum: -> { OpenAI::Beta::Threads::Run::IncompleteDetails::Reason }
  262. # @!method initialize(reason: nil)
  263. # Some parameter documentations has been truncated, see
  264. # {OpenAI::Models::Beta::Threads::Run::IncompleteDetails} for more details.
  265. #
  266. # Details on why the run is incomplete. Will be `null` if the run is not
  267. # incomplete.
  268. #
  269. # @param reason [Symbol, OpenAI::Models::Beta::Threads::Run::IncompleteDetails::Reason] The reason why the run is incomplete. This will point to which specific token li
  270. # The reason why the run is incomplete. This will point to which specific token
  271. # limit was reached over the course of the run.
  272. #
  273. # @see OpenAI::Models::Beta::Threads::Run::IncompleteDetails#reason
  274. 1 module Reason
  275. 1 extend OpenAI::Internal::Type::Enum
  276. 1 MAX_COMPLETION_TOKENS = :max_completion_tokens
  277. 1 MAX_PROMPT_TOKENS = :max_prompt_tokens
  278. # @!method self.values
  279. # @return [Array<Symbol>]
  280. end
  281. end
  282. # @see OpenAI::Models::Beta::Threads::Run#last_error
  283. 1 class LastError < OpenAI::Internal::Type::BaseModel
  284. # @!attribute code
  285. # One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
  286. #
  287. # @return [Symbol, OpenAI::Models::Beta::Threads::Run::LastError::Code]
  288. 1 required :code, enum: -> { OpenAI::Beta::Threads::Run::LastError::Code }
  289. # @!attribute message
  290. # A human-readable description of the error.
  291. #
  292. # @return [String]
  293. 1 required :message, String
  294. # @!method initialize(code:, message:)
  295. # The last error associated with this run. Will be `null` if there are no errors.
  296. #
  297. # @param code [Symbol, OpenAI::Models::Beta::Threads::Run::LastError::Code] One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
  298. #
  299. # @param message [String] A human-readable description of the error.
  300. # One of `server_error`, `rate_limit_exceeded`, or `invalid_prompt`.
  301. #
  302. # @see OpenAI::Models::Beta::Threads::Run::LastError#code
  303. 1 module Code
  304. 1 extend OpenAI::Internal::Type::Enum
  305. 1 SERVER_ERROR = :server_error
  306. 1 RATE_LIMIT_EXCEEDED = :rate_limit_exceeded
  307. 1 INVALID_PROMPT = :invalid_prompt
  308. # @!method self.values
  309. # @return [Array<Symbol>]
  310. end
  311. end
  312. # @see OpenAI::Models::Beta::Threads::Run#required_action
  313. 1 class RequiredAction < OpenAI::Internal::Type::BaseModel
  314. # @!attribute submit_tool_outputs
  315. # Details on the tool outputs needed for this run to continue.
  316. #
  317. # @return [OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs]
  318. 1 required :submit_tool_outputs,
  319. -> {
  320. OpenAI::Beta::Threads::Run::RequiredAction::SubmitToolOutputs
  321. }
  322. # @!attribute type
  323. # For now, this is always `submit_tool_outputs`.
  324. #
  325. # @return [Symbol, :submit_tool_outputs]
  326. 1 required :type, const: :submit_tool_outputs
  327. # @!method initialize(submit_tool_outputs:, type: :submit_tool_outputs)
  328. # Details on the action required to continue the run. Will be `null` if no action
  329. # is required.
  330. #
  331. # @param submit_tool_outputs [OpenAI::Models::Beta::Threads::Run::RequiredAction::SubmitToolOutputs] Details on the tool outputs needed for this run to continue.
  332. #
  333. # @param type [Symbol, :submit_tool_outputs] For now, this is always `submit_tool_outputs`.
  334. # @see OpenAI::Models::Beta::Threads::Run::RequiredAction#submit_tool_outputs
  335. 1 class SubmitToolOutputs < OpenAI::Internal::Type::BaseModel
  336. # @!attribute tool_calls
  337. # A list of the relevant tool calls.
  338. #
  339. # @return [Array<OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall>]
  340. 1 required :tool_calls,
  341. -> {
  342. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::Threads::RequiredActionFunctionToolCall]
  343. }
  344. # @!method initialize(tool_calls:)
  345. # Details on the tool outputs needed for this run to continue.
  346. #
  347. # @param tool_calls [Array<OpenAI::Models::Beta::Threads::RequiredActionFunctionToolCall>] A list of the relevant tool calls.
  348. end
  349. end
  350. # @see OpenAI::Models::Beta::Threads::Run#truncation_strategy
  351. 1 class TruncationStrategy < OpenAI::Internal::Type::BaseModel
  352. # @!attribute type
  353. # The truncation strategy to use for the thread. The default is `auto`. If set to
  354. # `last_messages`, the thread will be truncated to the n most recent messages in
  355. # the thread. When set to `auto`, messages in the middle of the thread will be
  356. # dropped to fit the context length of the model, `max_prompt_tokens`.
  357. #
  358. # @return [Symbol, OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type]
  359. 1 required :type, enum: -> { OpenAI::Beta::Threads::Run::TruncationStrategy::Type }
  360. # @!attribute last_messages
  361. # The number of most recent messages from the thread when constructing the context
  362. # for the run.
  363. #
  364. # @return [Integer, nil]
  365. 1 optional :last_messages, Integer, nil?: true
  366. # @!method initialize(type:, last_messages: nil)
  367. # Some parameter documentations has been truncated, see
  368. # {OpenAI::Models::Beta::Threads::Run::TruncationStrategy} for more details.
  369. #
  370. # Controls for how a thread will be truncated prior to the run. Use this to
  371. # control the intial context window of the run.
  372. #
  373. # @param type [Symbol, OpenAI::Models::Beta::Threads::Run::TruncationStrategy::Type] The truncation strategy to use for the thread. The default is `auto`. If set to
  374. #
  375. # @param last_messages [Integer, nil] The number of most recent messages from the thread when constructing the context
  376. # The truncation strategy to use for the thread. The default is `auto`. If set to
  377. # `last_messages`, the thread will be truncated to the n most recent messages in
  378. # the thread. When set to `auto`, messages in the middle of the thread will be
  379. # dropped to fit the context length of the model, `max_prompt_tokens`.
  380. #
  381. # @see OpenAI::Models::Beta::Threads::Run::TruncationStrategy#type
  382. 1 module Type
  383. 1 extend OpenAI::Internal::Type::Enum
  384. 1 AUTO = :auto
  385. 1 LAST_MESSAGES = :last_messages
  386. # @!method self.values
  387. # @return [Array<Symbol>]
  388. end
  389. end
  390. # @see OpenAI::Models::Beta::Threads::Run#usage
  391. 1 class Usage < OpenAI::Internal::Type::BaseModel
  392. # @!attribute completion_tokens
  393. # Number of completion tokens used over the course of the run.
  394. #
  395. # @return [Integer]
  396. 1 required :completion_tokens, Integer
  397. # @!attribute prompt_tokens
  398. # Number of prompt tokens used over the course of the run.
  399. #
  400. # @return [Integer]
  401. 1 required :prompt_tokens, Integer
  402. # @!attribute total_tokens
  403. # Total number of tokens used (prompt + completion).
  404. #
  405. # @return [Integer]
  406. 1 required :total_tokens, Integer
  407. # @!method initialize(completion_tokens:, prompt_tokens:, total_tokens:)
  408. # Usage statistics related to the run. This value will be `null` if the run is not
  409. # in a terminal state (i.e. `in_progress`, `queued`, etc.).
  410. #
  411. # @param completion_tokens [Integer] Number of completion tokens used over the course of the run.
  412. #
  413. # @param prompt_tokens [Integer] Number of prompt tokens used over the course of the run.
  414. #
  415. # @param total_tokens [Integer] Total number of tokens used (prompt + completion).
  416. end
  417. end
  418. end
  419. end
  420. end
  421. end

openai-ruby/lib/openai/models/beta/threads/run_cancel_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Runs#cancel
  7. 1 class RunCancelParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute thread_id
  11. #
  12. # @return [String]
  13. 1 required :thread_id, String
  14. # @!method initialize(thread_id:, request_options: {})
  15. # @param thread_id [String]
  16. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  17. end
  18. end
  19. end
  20. end
  21. end

openai-ruby/lib/openai/models/beta/threads/run_create_params.rb

88.06% lines covered

100.0% branches covered

67 relevant lines. 59 lines covered and 8 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Runs#create
  7. #
  8. # @see OpenAI::Resources::Beta::Threads::Runs#create_stream_raw
  9. 1 class RunCreateParams < OpenAI::Internal::Type::BaseModel
  10. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  11. 1 include OpenAI::Internal::Type::RequestParameters
  12. # @!attribute assistant_id
  13. # The ID of the
  14. # [assistant](https://platform.openai.com/docs/api-reference/assistants) to use to
  15. # execute this run.
  16. #
  17. # @return [String]
  18. 1 required :assistant_id, String
  19. # @!attribute include
  20. # A list of additional fields to include in the response. Currently the only
  21. # supported value is `step_details.tool_calls[*].file_search.results[*].content`
  22. # to fetch the file search result content.
  23. #
  24. # See the
  25. # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
  26. # for more information.
  27. #
  28. # @return [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>, nil]
  29. 1 optional :include,
  30. -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Beta::Threads::Runs::RunStepInclude] }
  31. # @!attribute additional_instructions
  32. # Appends additional instructions at the end of the instructions for the run. This
  33. # is useful for modifying the behavior on a per-run basis without overriding other
  34. # instructions.
  35. #
  36. # @return [String, nil]
  37. 1 optional :additional_instructions, String, nil?: true
  38. # @!attribute additional_messages
  39. # Adds additional messages to the thread before creating the run.
  40. #
  41. # @return [Array<OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage>, nil]
  42. 1 optional :additional_messages,
  43. -> {
  44. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::Threads::RunCreateParams::AdditionalMessage]
  45. },
  46. nil?: true
  47. # @!attribute instructions
  48. # Overrides the
  49. # [instructions](https://platform.openai.com/docs/api-reference/assistants/createAssistant)
  50. # of the assistant. This is useful for modifying the behavior on a per-run basis.
  51. #
  52. # @return [String, nil]
  53. 1 optional :instructions, String, nil?: true
  54. # @!attribute max_completion_tokens
  55. # The maximum number of completion tokens that may be used over the course of the
  56. # run. The run will make a best effort to use only the number of completion tokens
  57. # specified, across multiple turns of the run. If the run exceeds the number of
  58. # completion tokens specified, the run will end with status `incomplete`. See
  59. # `incomplete_details` for more info.
  60. #
  61. # @return [Integer, nil]
  62. 1 optional :max_completion_tokens, Integer, nil?: true
  63. # @!attribute max_prompt_tokens
  64. # The maximum number of prompt tokens that may be used over the course of the run.
  65. # The run will make a best effort to use only the number of prompt tokens
  66. # specified, across multiple turns of the run. If the run exceeds the number of
  67. # prompt tokens specified, the run will end with status `incomplete`. See
  68. # `incomplete_details` for more info.
  69. #
  70. # @return [Integer, nil]
  71. 1 optional :max_prompt_tokens, Integer, nil?: true
  72. # @!attribute metadata
  73. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  74. # for storing additional information about the object in a structured format, and
  75. # querying for objects via API or the dashboard.
  76. #
  77. # Keys are strings with a maximum length of 64 characters. Values are strings with
  78. # a maximum length of 512 characters.
  79. #
  80. # @return [Hash{Symbol=>String}, nil]
  81. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  82. # @!attribute model
  83. # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
  84. # be used to execute this run. If a value is provided here, it will override the
  85. # model associated with the assistant. If not, the model associated with the
  86. # assistant will be used.
  87. #
  88. # @return [String, Symbol, OpenAI::Models::ChatModel, nil]
  89. 1 optional :model, union: -> { OpenAI::Beta::Threads::RunCreateParams::Model }, nil?: true
  90. # @!attribute parallel_tool_calls
  91. # Whether to enable
  92. # [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
  93. # during tool use.
  94. #
  95. # @return [Boolean, nil]
  96. 1 optional :parallel_tool_calls, OpenAI::Internal::Type::Boolean
  97. # @!attribute reasoning_effort
  98. # **o-series models only**
  99. #
  100. # Constrains effort on reasoning for
  101. # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
  102. # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
  103. # result in faster responses and fewer tokens used on reasoning in a response.
  104. #
  105. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  106. 1 optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  107. # @!attribute response_format
  108. # Specifies the format that the model must output. Compatible with
  109. # [GPT-4o](https://platform.openai.com/docs/models#gpt-4o),
  110. # [GPT-4 Turbo](https://platform.openai.com/docs/models#gpt-4-turbo-and-gpt-4),
  111. # and all GPT-3.5 Turbo models since `gpt-3.5-turbo-1106`.
  112. #
  113. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  114. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  115. # in the
  116. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  117. #
  118. # Setting to `{ "type": "json_object" }` enables JSON mode, which ensures the
  119. # message the model generates is valid JSON.
  120. #
  121. # **Important:** when using JSON mode, you **must** also instruct the model to
  122. # produce JSON yourself via a system or user message. Without this, the model may
  123. # generate an unending stream of whitespace until the generation reaches the token
  124. # limit, resulting in a long-running and seemingly "stuck" request. Also note that
  125. # the message content may be partially cut off if `finish_reason="length"`, which
  126. # indicates the generation exceeded `max_tokens` or the conversation exceeded the
  127. # max context length.
  128. #
  129. # @return [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil]
  130. 1 optional :response_format, union: -> { OpenAI::Beta::AssistantResponseFormatOption }, nil?: true
  131. # @!attribute temperature
  132. # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  133. # make the output more random, while lower values like 0.2 will make it more
  134. # focused and deterministic.
  135. #
  136. # @return [Float, nil]
  137. 1 optional :temperature, Float, nil?: true
  138. # @!attribute tool_choice
  139. # Controls which (if any) tool is called by the model. `none` means the model will
  140. # not call any tools and instead generates a message. `auto` is the default value
  141. # and means the model can pick between generating a message or calling one or more
  142. # tools. `required` means the model must call one or more tools before responding
  143. # to the user. Specifying a particular tool like `{"type": "file_search"}` or
  144. # `{"type": "function", "function": {"name": "my_function"}}` forces the model to
  145. # call that tool.
  146. #
  147. # @return [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil]
  148. 1 optional :tool_choice, union: -> { OpenAI::Beta::AssistantToolChoiceOption }, nil?: true
  149. # @!attribute tools
  150. # Override the tools the assistant can use for this run. This is useful for
  151. # modifying the behavior on a per-run basis.
  152. #
  153. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil]
  154. 1 optional :tools,
  155. -> {
  156. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::AssistantTool]
  157. },
  158. nil?: true
  159. # @!attribute top_p
  160. # An alternative to sampling with temperature, called nucleus sampling, where the
  161. # model considers the results of the tokens with top_p probability mass. So 0.1
  162. # means only the tokens comprising the top 10% probability mass are considered.
  163. #
  164. # We generally recommend altering this or temperature but not both.
  165. #
  166. # @return [Float, nil]
  167. 1 optional :top_p, Float, nil?: true
  168. # @!attribute truncation_strategy
  169. # Controls for how a thread will be truncated prior to the run. Use this to
  170. # control the intial context window of the run.
  171. #
  172. # @return [OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy, nil]
  173. 1 optional :truncation_strategy,
  174. -> { OpenAI::Beta::Threads::RunCreateParams::TruncationStrategy },
  175. nil?: true
  176. # @!method initialize(assistant_id:, include: nil, additional_instructions: nil, additional_messages: nil, instructions: nil, max_completion_tokens: nil, max_prompt_tokens: nil, metadata: nil, model: nil, parallel_tool_calls: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_choice: nil, tools: nil, top_p: nil, truncation_strategy: nil, request_options: {})
  177. # Some parameter documentations has been truncated, see
  178. # {OpenAI::Models::Beta::Threads::RunCreateParams} for more details.
  179. #
  180. # @param assistant_id [String] The ID of the [assistant](https://platform.openai.com/docs/api-reference/assista
  181. #
  182. # @param include [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>] A list of additional fields to include in the response. Currently the only suppo
  183. #
  184. # @param additional_instructions [String, nil] Appends additional instructions at the end of the instructions for the run. This
  185. #
  186. # @param additional_messages [Array<OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage>, nil] Adds additional messages to the thread before creating the run.
  187. #
  188. # @param instructions [String, nil] Overrides the [instructions](https://platform.openai.com/docs/api-reference/assi
  189. #
  190. # @param max_completion_tokens [Integer, nil] The maximum number of completion tokens that may be used over the course of the
  191. #
  192. # @param max_prompt_tokens [Integer, nil] The maximum number of prompt tokens that may be used over the course of the run.
  193. #
  194. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  195. #
  196. # @param model [String, Symbol, OpenAI::Models::ChatModel, nil] The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
  197. #
  198. # @param parallel_tool_calls [Boolean] Whether to enable [parallel function calling](https://platform.openai.com/docs/g
  199. #
  200. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] **o-series models only**
  201. #
  202. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  203. #
  204. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  205. #
  206. # @param tool_choice [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil] Controls which (if any) tool is called by the model.
  207. #
  208. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil] Override the tools the assistant can use for this run. This is useful for modify
  209. #
  210. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  211. #
  212. # @param truncation_strategy [OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy, nil] Controls for how a thread will be truncated prior to the run. Use this to contro
  213. #
  214. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  215. 1 class AdditionalMessage < OpenAI::Internal::Type::BaseModel
  216. # @!attribute content
  217. # The text contents of the message.
  218. #
  219. # @return [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>]
  220. 1 required :content,
  221. union: -> {
  222. OpenAI::Beta::Threads::RunCreateParams::AdditionalMessage::Content
  223. }
  224. # @!attribute role
  225. # The role of the entity that is creating the message. Allowed values include:
  226. #
  227. # - `user`: Indicates the message is sent by an actual user and should be used in
  228. # most cases to represent user-generated messages.
  229. # - `assistant`: Indicates the message is generated by the assistant. Use this
  230. # value to insert messages from the assistant into the conversation.
  231. #
  232. # @return [Symbol, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role]
  233. 1 required :role, enum: -> { OpenAI::Beta::Threads::RunCreateParams::AdditionalMessage::Role }
  234. # @!attribute attachments
  235. # A list of files attached to the message, and the tools they should be added to.
  236. #
  237. # @return [Array<OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment>, nil]
  238. 1 optional :attachments,
  239. -> {
  240. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment]
  241. },
  242. nil?: true
  243. # @!attribute metadata
  244. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  245. # for storing additional information about the object in a structured format, and
  246. # querying for objects via API or the dashboard.
  247. #
  248. # Keys are strings with a maximum length of 64 characters. Values are strings with
  249. # a maximum length of 512 characters.
  250. #
  251. # @return [Hash{Symbol=>String}, nil]
  252. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  253. # @!method initialize(content:, role:, attachments: nil, metadata: nil)
  254. # Some parameter documentations has been truncated, see
  255. # {OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage} for more
  256. # details.
  257. #
  258. # @param content [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>] The text contents of the message.
  259. #
  260. # @param role [Symbol, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Role] The role of the entity that is creating the message. Allowed values include:
  261. #
  262. # @param attachments [Array<OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment>, nil] A list of files attached to the message, and the tools they should be added to.
  263. #
  264. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  265. # The text contents of the message.
  266. #
  267. # @see OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage#content
  268. 1 module Content
  269. 1 extend OpenAI::Internal::Type::Union
  270. # The text contents of the message.
  271. 1 variant String
  272. # An array of content parts with a defined type, each can be of type `text` or images can be passed with `image_url` or `image_file`. Image types are only supported on [Vision-compatible models](https://platform.openai.com/docs/models).
  273. 1 variant -> { OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Content::MessageContentPartParamArray }
  274. # @!method self.variants
  275. # @return [Array(String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>)]
  276. # @type [OpenAI::Internal::Type::Converter]
  277. MessageContentPartParamArray =
  278. 1 OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Beta::Threads::MessageContentPartParam }]
  279. end
  280. # The role of the entity that is creating the message. Allowed values include:
  281. #
  282. # - `user`: Indicates the message is sent by an actual user and should be used in
  283. # most cases to represent user-generated messages.
  284. # - `assistant`: Indicates the message is generated by the assistant. Use this
  285. # value to insert messages from the assistant into the conversation.
  286. #
  287. # @see OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage#role
  288. 1 module Role
  289. 1 extend OpenAI::Internal::Type::Enum
  290. 1 USER = :user
  291. 1 ASSISTANT = :assistant
  292. # @!method self.values
  293. # @return [Array<Symbol>]
  294. end
  295. 1 class Attachment < OpenAI::Internal::Type::BaseModel
  296. # @!attribute file_id
  297. # The ID of the file to attach to the message.
  298. #
  299. # @return [String, nil]
  300. 1 optional :file_id, String
  301. # @!attribute tools
  302. # The tools to add this file to.
  303. #
  304. # @return [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch>, nil]
  305. 1 optional :tools,
  306. -> {
  307. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool]
  308. }
  309. # @!method initialize(file_id: nil, tools: nil)
  310. # @param file_id [String] The ID of the file to attach to the message.
  311. #
  312. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch>] The tools to add this file to.
  313. 1 module Tool
  314. 1 extend OpenAI::Internal::Type::Union
  315. 1 discriminator :type
  316. 1 variant :code_interpreter, -> { OpenAI::Beta::CodeInterpreterTool }
  317. 1 variant :file_search,
  318. -> {
  319. OpenAI::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch
  320. }
  321. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  322. # @!attribute type
  323. # The type of tool being defined: `file_search`
  324. #
  325. # @return [Symbol, :file_search]
  326. 1 required :type, const: :file_search
  327. # @!method initialize(type: :file_search)
  328. # @param type [Symbol, :file_search] The type of tool being defined: `file_search`
  329. end
  330. # @!method self.variants
  331. # @return [Array(OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage::Attachment::Tool::FileSearch)]
  332. end
  333. end
  334. end
  335. # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
  336. # be used to execute this run. If a value is provided here, it will override the
  337. # model associated with the assistant. If not, the model associated with the
  338. # assistant will be used.
  339. 1 module Model
  340. 1 extend OpenAI::Internal::Type::Union
  341. 1 variant String
  342. # The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to be used to execute this run. If a value is provided here, it will override the model associated with the assistant. If not, the model associated with the assistant will be used.
  343. 1 variant enum: -> { OpenAI::ChatModel }
  344. # @!method self.variants
  345. # @return [Array(String, Symbol, OpenAI::Models::ChatModel)]
  346. end
  347. 1 class TruncationStrategy < OpenAI::Internal::Type::BaseModel
  348. # @!attribute type
  349. # The truncation strategy to use for the thread. The default is `auto`. If set to
  350. # `last_messages`, the thread will be truncated to the n most recent messages in
  351. # the thread. When set to `auto`, messages in the middle of the thread will be
  352. # dropped to fit the context length of the model, `max_prompt_tokens`.
  353. #
  354. # @return [Symbol, OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type]
  355. 1 required :type, enum: -> { OpenAI::Beta::Threads::RunCreateParams::TruncationStrategy::Type }
  356. # @!attribute last_messages
  357. # The number of most recent messages from the thread when constructing the context
  358. # for the run.
  359. #
  360. # @return [Integer, nil]
  361. 1 optional :last_messages, Integer, nil?: true
  362. # @!method initialize(type:, last_messages: nil)
  363. # Some parameter documentations has been truncated, see
  364. # {OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy} for more
  365. # details.
  366. #
  367. # Controls for how a thread will be truncated prior to the run. Use this to
  368. # control the intial context window of the run.
  369. #
  370. # @param type [Symbol, OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy::Type] The truncation strategy to use for the thread. The default is `auto`. If set to
  371. #
  372. # @param last_messages [Integer, nil] The number of most recent messages from the thread when constructing the context
  373. # The truncation strategy to use for the thread. The default is `auto`. If set to
  374. # `last_messages`, the thread will be truncated to the n most recent messages in
  375. # the thread. When set to `auto`, messages in the middle of the thread will be
  376. # dropped to fit the context length of the model, `max_prompt_tokens`.
  377. #
  378. # @see OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy#type
  379. 1 module Type
  380. 1 extend OpenAI::Internal::Type::Enum
  381. 1 AUTO = :auto
  382. 1 LAST_MESSAGES = :last_messages
  383. # @!method self.values
  384. # @return [Array<Symbol>]
  385. end
  386. end
  387. end
  388. end
  389. end
  390. end
  391. end

openai-ruby/lib/openai/models/beta/threads/run_list_params.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Runs#list
  7. 1 class RunListParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute after
  11. # A cursor for use in pagination. `after` is an object ID that defines your place
  12. # in the list. For instance, if you make a list request and receive 100 objects,
  13. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  14. # fetch the next page of the list.
  15. #
  16. # @return [String, nil]
  17. 1 optional :after, String
  18. # @!attribute before
  19. # A cursor for use in pagination. `before` is an object ID that defines your place
  20. # in the list. For instance, if you make a list request and receive 100 objects,
  21. # starting with obj_foo, your subsequent call can include before=obj_foo in order
  22. # to fetch the previous page of the list.
  23. #
  24. # @return [String, nil]
  25. 1 optional :before, String
  26. # @!attribute limit
  27. # A limit on the number of objects to be returned. Limit can range between 1 and
  28. # 100, and the default is 20.
  29. #
  30. # @return [Integer, nil]
  31. 1 optional :limit, Integer
  32. # @!attribute order
  33. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  34. # order and `desc` for descending order.
  35. #
  36. # @return [Symbol, OpenAI::Models::Beta::Threads::RunListParams::Order, nil]
  37. 1 optional :order, enum: -> { OpenAI::Beta::Threads::RunListParams::Order }
  38. # @!method initialize(after: nil, before: nil, limit: nil, order: nil, request_options: {})
  39. # Some parameter documentations has been truncated, see
  40. # {OpenAI::Models::Beta::Threads::RunListParams} for more details.
  41. #
  42. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  43. #
  44. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  45. #
  46. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  47. #
  48. # @param order [Symbol, OpenAI::Models::Beta::Threads::RunListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  49. #
  50. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  51. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  52. # order and `desc` for descending order.
  53. 1 module Order
  54. 1 extend OpenAI::Internal::Type::Enum
  55. 1 ASC = :asc
  56. 1 DESC = :desc
  57. # @!method self.values
  58. # @return [Array<Symbol>]
  59. end
  60. end
  61. end
  62. end
  63. end
  64. end

openai-ruby/lib/openai/models/beta/threads/run_retrieve_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Runs#retrieve
  7. 1 class RunRetrieveParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute thread_id
  11. #
  12. # @return [String]
  13. 1 required :thread_id, String
  14. # @!method initialize(thread_id:, request_options: {})
  15. # @param thread_id [String]
  16. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  17. end
  18. end
  19. end
  20. end
  21. end

openai-ruby/lib/openai/models/beta/threads/run_status.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # The status of the run, which can be either `queued`, `in_progress`,
  7. # `requires_action`, `cancelling`, `cancelled`, `failed`, `completed`,
  8. # `incomplete`, or `expired`.
  9. 1 module RunStatus
  10. 1 extend OpenAI::Internal::Type::Enum
  11. 1 QUEUED = :queued
  12. 1 IN_PROGRESS = :in_progress
  13. 1 REQUIRES_ACTION = :requires_action
  14. 1 CANCELLING = :cancelling
  15. 1 CANCELLED = :cancelled
  16. 1 FAILED = :failed
  17. 1 COMPLETED = :completed
  18. 1 INCOMPLETE = :incomplete
  19. 1 EXPIRED = :expired
  20. # @!method self.values
  21. # @return [Array<Symbol>]
  22. end
  23. end
  24. end
  25. end
  26. end

openai-ruby/lib/openai/models/beta/threads/run_submit_tool_outputs_params.rb

92.31% lines covered

100.0% branches covered

13 relevant lines. 12 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Runs#submit_tool_outputs
  7. #
  8. # @see OpenAI::Resources::Beta::Threads::Runs#submit_tool_outputs_stream_raw
  9. 1 class RunSubmitToolOutputsParams < OpenAI::Internal::Type::BaseModel
  10. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  11. 1 include OpenAI::Internal::Type::RequestParameters
  12. # @!attribute thread_id
  13. #
  14. # @return [String]
  15. 1 required :thread_id, String
  16. # @!attribute tool_outputs
  17. # A list of tools for which the outputs are being submitted.
  18. #
  19. # @return [Array<OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput>]
  20. 1 required :tool_outputs,
  21. -> {
  22. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput]
  23. }
  24. # @!method initialize(thread_id:, tool_outputs:, request_options: {})
  25. # @param thread_id [String]
  26. #
  27. # @param tool_outputs [Array<OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput>] A list of tools for which the outputs are being submitted.
  28. #
  29. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  30. 1 class ToolOutput < OpenAI::Internal::Type::BaseModel
  31. # @!attribute output
  32. # The output of the tool call to be submitted to continue the run.
  33. #
  34. # @return [String, nil]
  35. 1 optional :output, String
  36. # @!attribute tool_call_id
  37. # The ID of the tool call in the `required_action` object within the run object
  38. # the output is being submitted for.
  39. #
  40. # @return [String, nil]
  41. 1 optional :tool_call_id, String
  42. # @!method initialize(output: nil, tool_call_id: nil)
  43. # Some parameter documentations has been truncated, see
  44. # {OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput} for more
  45. # details.
  46. #
  47. # @param output [String] The output of the tool call to be submitted to continue the run.
  48. #
  49. # @param tool_call_id [String] The ID of the tool call in the `required_action` object within the run object th
  50. end
  51. end
  52. end
  53. end
  54. end
  55. end

openai-ruby/lib/openai/models/beta/threads/run_update_params.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. # @see OpenAI::Resources::Beta::Threads::Runs#update
  7. 1 class RunUpdateParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute thread_id
  11. #
  12. # @return [String]
  13. 1 required :thread_id, String
  14. # @!attribute metadata
  15. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  16. # for storing additional information about the object in a structured format, and
  17. # querying for objects via API or the dashboard.
  18. #
  19. # Keys are strings with a maximum length of 64 characters. Values are strings with
  20. # a maximum length of 512 characters.
  21. #
  22. # @return [Hash{Symbol=>String}, nil]
  23. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  24. # @!method initialize(thread_id:, metadata: nil, request_options: {})
  25. # Some parameter documentations has been truncated, see
  26. # {OpenAI::Models::Beta::Threads::RunUpdateParams} for more details.
  27. #
  28. # @param thread_id [String]
  29. #
  30. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  31. #
  32. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  33. end
  34. end
  35. end
  36. end
  37. end

openai-ruby/lib/openai/models/beta/threads/runs/code_interpreter_logs.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class CodeInterpreterLogs < OpenAI::Internal::Type::BaseModel
  8. # @!attribute index
  9. # The index of the output in the outputs array.
  10. #
  11. # @return [Integer]
  12. 1 required :index, Integer
  13. # @!attribute type
  14. # Always `logs`.
  15. #
  16. # @return [Symbol, :logs]
  17. 1 required :type, const: :logs
  18. # @!attribute logs
  19. # The text output from the Code Interpreter tool call.
  20. #
  21. # @return [String, nil]
  22. 1 optional :logs, String
  23. # @!method initialize(index:, logs: nil, type: :logs)
  24. # Text output from the Code Interpreter tool call as part of a run step.
  25. #
  26. # @param index [Integer] The index of the output in the outputs array.
  27. #
  28. # @param logs [String] The text output from the Code Interpreter tool call.
  29. #
  30. # @param type [Symbol, :logs] Always `logs`.
  31. end
  32. end
  33. end
  34. end
  35. end
  36. end

openai-ruby/lib/openai/models/beta/threads/runs/code_interpreter_output_image.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class CodeInterpreterOutputImage < OpenAI::Internal::Type::BaseModel
  8. # @!attribute index
  9. # The index of the output in the outputs array.
  10. #
  11. # @return [Integer]
  12. 1 required :index, Integer
  13. # @!attribute type
  14. # Always `image`.
  15. #
  16. # @return [Symbol, :image]
  17. 1 required :type, const: :image
  18. # @!attribute image
  19. #
  20. # @return [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image, nil]
  21. 1 optional :image, -> { OpenAI::Beta::Threads::Runs::CodeInterpreterOutputImage::Image }
  22. # @!method initialize(index:, image: nil, type: :image)
  23. # @param index [Integer] The index of the output in the outputs array.
  24. #
  25. # @param image [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image]
  26. #
  27. # @param type [Symbol, :image] Always `image`.
  28. # @see OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage#image
  29. 1 class Image < OpenAI::Internal::Type::BaseModel
  30. # @!attribute file_id
  31. # The [file](https://platform.openai.com/docs/api-reference/files) ID of the
  32. # image.
  33. #
  34. # @return [String, nil]
  35. 1 optional :file_id, String
  36. # @!method initialize(file_id: nil)
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage::Image} for
  39. # more details.
  40. #
  41. # @param file_id [String] The [file](https://platform.openai.com/docs/api-reference/files) ID of the image
  42. end
  43. end
  44. end
  45. end
  46. end
  47. end
  48. end

openai-ruby/lib/openai/models/beta/threads/runs/code_interpreter_tool_call.rb

83.33% lines covered

100.0% branches covered

30 relevant lines. 25 lines covered and 5 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class CodeInterpreterToolCall < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # The ID of the tool call.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute code_interpreter
  14. # The Code Interpreter tool call definition.
  15. #
  16. # @return [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter]
  17. 1 required :code_interpreter,
  18. -> {
  19. OpenAI::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter
  20. }
  21. # @!attribute type
  22. # The type of tool call. This is always going to be `code_interpreter` for this
  23. # type of tool call.
  24. #
  25. # @return [Symbol, :code_interpreter]
  26. 1 required :type, const: :code_interpreter
  27. # @!method initialize(id:, code_interpreter:, type: :code_interpreter)
  28. # Some parameter documentations has been truncated, see
  29. # {OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall} for more details.
  30. #
  31. # Details of the Code Interpreter tool call the run step was involved in.
  32. #
  33. # @param id [String] The ID of the tool call.
  34. #
  35. # @param code_interpreter [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter] The Code Interpreter tool call definition.
  36. #
  37. # @param type [Symbol, :code_interpreter] The type of tool call. This is always going to be `code_interpreter` for this ty
  38. # @see OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall#code_interpreter
  39. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  40. # @!attribute input
  41. # The input to the Code Interpreter tool call.
  42. #
  43. # @return [String]
  44. 1 required :input, String
  45. # @!attribute outputs
  46. # The outputs from the Code Interpreter tool call. Code Interpreter can output one
  47. # or more items, including text (`logs`) or images (`image`). Each of these are
  48. # represented by a different object type.
  49. #
  50. # @return [Array<OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image>]
  51. 1 required :outputs,
  52. -> {
  53. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output]
  54. }
  55. # @!method initialize(input:, outputs:)
  56. # Some parameter documentations has been truncated, see
  57. # {OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter}
  58. # for more details.
  59. #
  60. # The Code Interpreter tool call definition.
  61. #
  62. # @param input [String] The input to the Code Interpreter tool call.
  63. #
  64. # @param outputs [Array<OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image>] The outputs from the Code Interpreter tool call. Code Interpreter can output one
  65. # Text output from the Code Interpreter tool call as part of a run step.
  66. 1 module Output
  67. 1 extend OpenAI::Internal::Type::Union
  68. 1 discriminator :type
  69. # Text output from the Code Interpreter tool call as part of a run step.
  70. 1 variant :logs,
  71. -> {
  72. OpenAI::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs
  73. }
  74. 1 variant :image,
  75. -> {
  76. OpenAI::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image
  77. }
  78. 1 class Logs < OpenAI::Internal::Type::BaseModel
  79. # @!attribute logs
  80. # The text output from the Code Interpreter tool call.
  81. #
  82. # @return [String]
  83. 1 required :logs, String
  84. # @!attribute type
  85. # Always `logs`.
  86. #
  87. # @return [Symbol, :logs]
  88. 1 required :type, const: :logs
  89. # @!method initialize(logs:, type: :logs)
  90. # Text output from the Code Interpreter tool call as part of a run step.
  91. #
  92. # @param logs [String] The text output from the Code Interpreter tool call.
  93. #
  94. # @param type [Symbol, :logs] Always `logs`.
  95. end
  96. 1 class Image < OpenAI::Internal::Type::BaseModel
  97. # @!attribute image
  98. #
  99. # @return [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image]
  100. 1 required :image,
  101. -> {
  102. OpenAI::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image
  103. }
  104. # @!attribute type
  105. # Always `image`.
  106. #
  107. # @return [Symbol, :image]
  108. 1 required :type, const: :image
  109. # @!method initialize(image:, type: :image)
  110. # @param image [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image]
  111. #
  112. # @param type [Symbol, :image] Always `image`.
  113. # @see OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image#image
  114. 1 class Image < OpenAI::Internal::Type::BaseModel
  115. # @!attribute file_id
  116. # The [file](https://platform.openai.com/docs/api-reference/files) ID of the
  117. # image.
  118. #
  119. # @return [String]
  120. 1 required :file_id, String
  121. # @!method initialize(file_id:)
  122. # Some parameter documentations has been truncated, see
  123. # {OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image::Image}
  124. # for more details.
  125. #
  126. # @param file_id [String] The [file](https://platform.openai.com/docs/api-reference/files) ID of the image
  127. end
  128. end
  129. # @!method self.variants
  130. # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Logs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall::CodeInterpreter::Output::Image)]
  131. end
  132. end
  133. end
  134. end
  135. end
  136. end
  137. end
  138. end

openai-ruby/lib/openai/models/beta/threads/runs/code_interpreter_tool_call_delta.rb

90.0% lines covered

100.0% branches covered

20 relevant lines. 18 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class CodeInterpreterToolCallDelta < OpenAI::Internal::Type::BaseModel
  8. # @!attribute index
  9. # The index of the tool call in the tool calls array.
  10. #
  11. # @return [Integer]
  12. 1 required :index, Integer
  13. # @!attribute type
  14. # The type of tool call. This is always going to be `code_interpreter` for this
  15. # type of tool call.
  16. #
  17. # @return [Symbol, :code_interpreter]
  18. 1 required :type, const: :code_interpreter
  19. # @!attribute id
  20. # The ID of the tool call.
  21. #
  22. # @return [String, nil]
  23. 1 optional :id, String
  24. # @!attribute code_interpreter
  25. # The Code Interpreter tool call definition.
  26. #
  27. # @return [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter, nil]
  28. 1 optional :code_interpreter,
  29. -> { OpenAI::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter }
  30. # @!method initialize(index:, id: nil, code_interpreter: nil, type: :code_interpreter)
  31. # Some parameter documentations has been truncated, see
  32. # {OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta} for more
  33. # details.
  34. #
  35. # Details of the Code Interpreter tool call the run step was involved in.
  36. #
  37. # @param index [Integer] The index of the tool call in the tool calls array.
  38. #
  39. # @param id [String] The ID of the tool call.
  40. #
  41. # @param code_interpreter [OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter] The Code Interpreter tool call definition.
  42. #
  43. # @param type [Symbol, :code_interpreter] The type of tool call. This is always going to be `code_interpreter` for this ty
  44. # @see OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta#code_interpreter
  45. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  46. # @!attribute input
  47. # The input to the Code Interpreter tool call.
  48. #
  49. # @return [String, nil]
  50. 1 optional :input, String
  51. # @!attribute outputs
  52. # The outputs from the Code Interpreter tool call. Code Interpreter can output one
  53. # or more items, including text (`logs`) or images (`image`). Each of these are
  54. # represented by a different object type.
  55. #
  56. # @return [Array<OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage>, nil]
  57. 1 optional :outputs,
  58. -> {
  59. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter::Output]
  60. }
  61. # @!method initialize(input: nil, outputs: nil)
  62. # Some parameter documentations has been truncated, see
  63. # {OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta::CodeInterpreter}
  64. # for more details.
  65. #
  66. # The Code Interpreter tool call definition.
  67. #
  68. # @param input [String] The input to the Code Interpreter tool call.
  69. #
  70. # @param outputs [Array<OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage>] The outputs from the Code Interpreter tool call. Code Interpreter can output one
  71. # Text output from the Code Interpreter tool call as part of a run step.
  72. 1 module Output
  73. 1 extend OpenAI::Internal::Type::Union
  74. 1 discriminator :type
  75. # Text output from the Code Interpreter tool call as part of a run step.
  76. 1 variant :logs, -> { OpenAI::Beta::Threads::Runs::CodeInterpreterLogs }
  77. 1 variant :image, -> { OpenAI::Beta::Threads::Runs::CodeInterpreterOutputImage }
  78. # @!method self.variants
  79. # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterLogs, OpenAI::Models::Beta::Threads::Runs::CodeInterpreterOutputImage)]
  80. end
  81. end
  82. end
  83. end
  84. end
  85. end
  86. end
  87. end

openai-ruby/lib/openai/models/beta/threads/runs/file_search_tool_call.rb

85.71% lines covered

100.0% branches covered

35 relevant lines. 30 lines covered and 5 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class FileSearchToolCall < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # The ID of the tool call object.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute file_search
  14. # For now, this is always going to be an empty object.
  15. #
  16. # @return [OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch]
  17. 1 required :file_search, -> { OpenAI::Beta::Threads::Runs::FileSearchToolCall::FileSearch }
  18. # @!attribute type
  19. # The type of tool call. This is always going to be `file_search` for this type of
  20. # tool call.
  21. #
  22. # @return [Symbol, :file_search]
  23. 1 required :type, const: :file_search
  24. # @!method initialize(id:, file_search:, type: :file_search)
  25. # Some parameter documentations has been truncated, see
  26. # {OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall} for more details.
  27. #
  28. # @param id [String] The ID of the tool call object.
  29. #
  30. # @param file_search [OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch] For now, this is always going to be an empty object.
  31. #
  32. # @param type [Symbol, :file_search] The type of tool call. This is always going to be `file_search` for this type of
  33. # @see OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall#file_search
  34. 1 class FileSearch < OpenAI::Internal::Type::BaseModel
  35. # @!attribute ranking_options
  36. # The ranking options for the file search.
  37. #
  38. # @return [OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions, nil]
  39. 1 optional :ranking_options,
  40. -> { OpenAI::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions }
  41. # @!attribute results
  42. # The results of the file search.
  43. #
  44. # @return [Array<OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result>, nil]
  45. 1 optional :results,
  46. -> {
  47. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result]
  48. }
  49. # @!method initialize(ranking_options: nil, results: nil)
  50. # For now, this is always going to be an empty object.
  51. #
  52. # @param ranking_options [OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions] The ranking options for the file search.
  53. #
  54. # @param results [Array<OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result>] The results of the file search.
  55. # @see OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch#ranking_options
  56. 1 class RankingOptions < OpenAI::Internal::Type::BaseModel
  57. # @!attribute ranker
  58. # The ranker to use for the file search. If not specified will use the `auto`
  59. # ranker.
  60. #
  61. # @return [Symbol, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker]
  62. 1 required :ranker,
  63. enum: -> {
  64. OpenAI::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker
  65. }
  66. # @!attribute score_threshold
  67. # The score threshold for the file search. All values must be a floating point
  68. # number between 0 and 1.
  69. #
  70. # @return [Float]
  71. 1 required :score_threshold, Float
  72. # @!method initialize(ranker:, score_threshold:)
  73. # Some parameter documentations has been truncated, see
  74. # {OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions}
  75. # for more details.
  76. #
  77. # The ranking options for the file search.
  78. #
  79. # @param ranker [Symbol, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions::Ranker] The ranker to use for the file search. If not specified will use the `auto` rank
  80. #
  81. # @param score_threshold [Float] The score threshold for the file search. All values must be a floating point num
  82. # The ranker to use for the file search. If not specified will use the `auto`
  83. # ranker.
  84. #
  85. # @see OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::RankingOptions#ranker
  86. 1 module Ranker
  87. 1 extend OpenAI::Internal::Type::Enum
  88. 1 AUTO = :auto
  89. 1 DEFAULT_2024_08_21 = :default_2024_08_21
  90. # @!method self.values
  91. # @return [Array<Symbol>]
  92. end
  93. end
  94. 1 class Result < OpenAI::Internal::Type::BaseModel
  95. # @!attribute file_id
  96. # The ID of the file that result was found in.
  97. #
  98. # @return [String]
  99. 1 required :file_id, String
  100. # @!attribute file_name
  101. # The name of the file that result was found in.
  102. #
  103. # @return [String]
  104. 1 required :file_name, String
  105. # @!attribute score
  106. # The score of the result. All values must be a floating point number between 0
  107. # and 1.
  108. #
  109. # @return [Float]
  110. 1 required :score, Float
  111. # @!attribute content
  112. # The content of the result that was found. The content is only included if
  113. # requested via the include query parameter.
  114. #
  115. # @return [Array<OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content>, nil]
  116. 1 optional :content,
  117. -> {
  118. OpenAI::Internal::Type::ArrayOf[OpenAI::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content]
  119. }
  120. # @!method initialize(file_id:, file_name:, score:, content: nil)
  121. # Some parameter documentations has been truncated, see
  122. # {OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result}
  123. # for more details.
  124. #
  125. # A result instance of the file search.
  126. #
  127. # @param file_id [String] The ID of the file that result was found in.
  128. #
  129. # @param file_name [String] The name of the file that result was found in.
  130. #
  131. # @param score [Float] The score of the result. All values must be a floating point number between 0 an
  132. #
  133. # @param content [Array<OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content>] The content of the result that was found. The content is only included if reques
  134. 1 class Content < OpenAI::Internal::Type::BaseModel
  135. # @!attribute text
  136. # The text content of the file.
  137. #
  138. # @return [String, nil]
  139. 1 optional :text, String
  140. # @!attribute type
  141. # The type of the content.
  142. #
  143. # @return [Symbol, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type, nil]
  144. 1 optional :type,
  145. enum: -> {
  146. OpenAI::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type
  147. }
  148. # @!method initialize(text: nil, type: nil)
  149. # @param text [String] The text content of the file.
  150. #
  151. # @param type [Symbol, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content::Type] The type of the content.
  152. # The type of the content.
  153. #
  154. # @see OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall::FileSearch::Result::Content#type
  155. 1 module Type
  156. 1 extend OpenAI::Internal::Type::Enum
  157. 1 TEXT = :text
  158. # @!method self.values
  159. # @return [Array<Symbol>]
  160. end
  161. end
  162. end
  163. end
  164. end
  165. end
  166. end
  167. end
  168. end
  169. end

openai-ruby/lib/openai/models/beta/threads/runs/file_search_tool_call_delta.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class FileSearchToolCallDelta < OpenAI::Internal::Type::BaseModel
  8. # @!attribute file_search
  9. # For now, this is always going to be an empty object.
  10. #
  11. # @return [Object]
  12. 1 required :file_search, OpenAI::Internal::Type::Unknown
  13. # @!attribute index
  14. # The index of the tool call in the tool calls array.
  15. #
  16. # @return [Integer]
  17. 1 required :index, Integer
  18. # @!attribute type
  19. # The type of tool call. This is always going to be `file_search` for this type of
  20. # tool call.
  21. #
  22. # @return [Symbol, :file_search]
  23. 1 required :type, const: :file_search
  24. # @!attribute id
  25. # The ID of the tool call object.
  26. #
  27. # @return [String, nil]
  28. 1 optional :id, String
  29. # @!method initialize(file_search:, index:, id: nil, type: :file_search)
  30. # Some parameter documentations has been truncated, see
  31. # {OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta} for more details.
  32. #
  33. # @param file_search [Object] For now, this is always going to be an empty object.
  34. #
  35. # @param index [Integer] The index of the tool call in the tool calls array.
  36. #
  37. # @param id [String] The ID of the tool call object.
  38. #
  39. # @param type [Symbol, :file_search] The type of tool call. This is always going to be `file_search` for this type of
  40. end
  41. end
  42. end
  43. end
  44. end
  45. end

openai-ruby/lib/openai/models/beta/threads/runs/function_tool_call.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class FunctionToolCall < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # The ID of the tool call object.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute function
  14. # The definition of the function that was called.
  15. #
  16. # @return [OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function]
  17. 1 required :function, -> { OpenAI::Beta::Threads::Runs::FunctionToolCall::Function }
  18. # @!attribute type
  19. # The type of tool call. This is always going to be `function` for this type of
  20. # tool call.
  21. #
  22. # @return [Symbol, :function]
  23. 1 required :type, const: :function
  24. # @!method initialize(id:, function:, type: :function)
  25. # Some parameter documentations has been truncated, see
  26. # {OpenAI::Models::Beta::Threads::Runs::FunctionToolCall} for more details.
  27. #
  28. # @param id [String] The ID of the tool call object.
  29. #
  30. # @param function [OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function] The definition of the function that was called.
  31. #
  32. # @param type [Symbol, :function] The type of tool call. This is always going to be `function` for this type of to
  33. # @see OpenAI::Models::Beta::Threads::Runs::FunctionToolCall#function
  34. 1 class Function < OpenAI::Internal::Type::BaseModel
  35. # @!attribute arguments
  36. # The arguments passed to the function.
  37. #
  38. # @return [String]
  39. 1 required :arguments, String
  40. # @!attribute name
  41. # The name of the function.
  42. #
  43. # @return [String]
  44. 1 required :name, String
  45. # @!attribute output
  46. # The output of the function. This will be `null` if the outputs have not been
  47. # [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
  48. # yet.
  49. #
  50. # @return [String, nil]
  51. 1 required :output, String, nil?: true
  52. # @!method initialize(arguments:, name:, output:)
  53. # Some parameter documentations has been truncated, see
  54. # {OpenAI::Models::Beta::Threads::Runs::FunctionToolCall::Function} for more
  55. # details.
  56. #
  57. # The definition of the function that was called.
  58. #
  59. # @param arguments [String] The arguments passed to the function.
  60. #
  61. # @param name [String] The name of the function.
  62. #
  63. # @param output [String, nil] The output of the function. This will be `null` if the outputs have not been [su
  64. end
  65. end
  66. end
  67. end
  68. end
  69. end
  70. end

openai-ruby/lib/openai/models/beta/threads/runs/function_tool_call_delta.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class FunctionToolCallDelta < OpenAI::Internal::Type::BaseModel
  8. # @!attribute index
  9. # The index of the tool call in the tool calls array.
  10. #
  11. # @return [Integer]
  12. 1 required :index, Integer
  13. # @!attribute type
  14. # The type of tool call. This is always going to be `function` for this type of
  15. # tool call.
  16. #
  17. # @return [Symbol, :function]
  18. 1 required :type, const: :function
  19. # @!attribute id
  20. # The ID of the tool call object.
  21. #
  22. # @return [String, nil]
  23. 1 optional :id, String
  24. # @!attribute function
  25. # The definition of the function that was called.
  26. #
  27. # @return [OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function, nil]
  28. 1 optional :function, -> { OpenAI::Beta::Threads::Runs::FunctionToolCallDelta::Function }
  29. # @!method initialize(index:, id: nil, function: nil, type: :function)
  30. # Some parameter documentations has been truncated, see
  31. # {OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta} for more details.
  32. #
  33. # @param index [Integer] The index of the tool call in the tool calls array.
  34. #
  35. # @param id [String] The ID of the tool call object.
  36. #
  37. # @param function [OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function] The definition of the function that was called.
  38. #
  39. # @param type [Symbol, :function] The type of tool call. This is always going to be `function` for this type of to
  40. # @see OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta#function
  41. 1 class Function < OpenAI::Internal::Type::BaseModel
  42. # @!attribute arguments
  43. # The arguments passed to the function.
  44. #
  45. # @return [String, nil]
  46. 1 optional :arguments, String
  47. # @!attribute name
  48. # The name of the function.
  49. #
  50. # @return [String, nil]
  51. 1 optional :name, String
  52. # @!attribute output
  53. # The output of the function. This will be `null` if the outputs have not been
  54. # [submitted](https://platform.openai.com/docs/api-reference/runs/submitToolOutputs)
  55. # yet.
  56. #
  57. # @return [String, nil]
  58. 1 optional :output, String, nil?: true
  59. # @!method initialize(arguments: nil, name: nil, output: nil)
  60. # Some parameter documentations has been truncated, see
  61. # {OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta::Function} for more
  62. # details.
  63. #
  64. # The definition of the function that was called.
  65. #
  66. # @param arguments [String] The arguments passed to the function.
  67. #
  68. # @param name [String] The name of the function.
  69. #
  70. # @param output [String, nil] The output of the function. This will be `null` if the outputs have not been [su
  71. end
  72. end
  73. end
  74. end
  75. end
  76. end
  77. end

openai-ruby/lib/openai/models/beta/threads/runs/message_creation_step_details.rb

90.91% lines covered

100.0% branches covered

11 relevant lines. 10 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class MessageCreationStepDetails < OpenAI::Internal::Type::BaseModel
  8. # @!attribute message_creation
  9. #
  10. # @return [OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation]
  11. 1 required :message_creation,
  12. -> { OpenAI::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation }
  13. # @!attribute type
  14. # Always `message_creation`.
  15. #
  16. # @return [Symbol, :message_creation]
  17. 1 required :type, const: :message_creation
  18. # @!method initialize(message_creation:, type: :message_creation)
  19. # Details of the message creation by the run step.
  20. #
  21. # @param message_creation [OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails::MessageCreation]
  22. #
  23. # @param type [Symbol, :message_creation] Always `message_creation`.
  24. # @see OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails#message_creation
  25. 1 class MessageCreation < OpenAI::Internal::Type::BaseModel
  26. # @!attribute message_id
  27. # The ID of the message that was created by this run step.
  28. #
  29. # @return [String]
  30. 1 required :message_id, String
  31. # @!method initialize(message_id:)
  32. # @param message_id [String] The ID of the message that was created by this run step.
  33. end
  34. end
  35. end
  36. end
  37. end
  38. end
  39. end

openai-ruby/lib/openai/models/beta/threads/runs/run_step.rb

100.0% lines covered

100.0% branches covered

50 relevant lines. 50 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. # @see OpenAI::Resources::Beta::Threads::Runs::Steps#retrieve
  8. 1 class RunStep < OpenAI::Internal::Type::BaseModel
  9. # @!attribute id
  10. # The identifier of the run step, which can be referenced in API endpoints.
  11. #
  12. # @return [String]
  13. 1 required :id, String
  14. # @!attribute assistant_id
  15. # The ID of the
  16. # [assistant](https://platform.openai.com/docs/api-reference/assistants)
  17. # associated with the run step.
  18. #
  19. # @return [String]
  20. 1 required :assistant_id, String
  21. # @!attribute cancelled_at
  22. # The Unix timestamp (in seconds) for when the run step was cancelled.
  23. #
  24. # @return [Integer, nil]
  25. 1 required :cancelled_at, Integer, nil?: true
  26. # @!attribute completed_at
  27. # The Unix timestamp (in seconds) for when the run step completed.
  28. #
  29. # @return [Integer, nil]
  30. 1 required :completed_at, Integer, nil?: true
  31. # @!attribute created_at
  32. # The Unix timestamp (in seconds) for when the run step was created.
  33. #
  34. # @return [Integer]
  35. 1 required :created_at, Integer
  36. # @!attribute expired_at
  37. # The Unix timestamp (in seconds) for when the run step expired. A step is
  38. # considered expired if the parent run is expired.
  39. #
  40. # @return [Integer, nil]
  41. 1 required :expired_at, Integer, nil?: true
  42. # @!attribute failed_at
  43. # The Unix timestamp (in seconds) for when the run step failed.
  44. #
  45. # @return [Integer, nil]
  46. 1 required :failed_at, Integer, nil?: true
  47. # @!attribute last_error
  48. # The last error associated with this run step. Will be `null` if there are no
  49. # errors.
  50. #
  51. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep::LastError, nil]
  52. 1 required :last_error, -> { OpenAI::Beta::Threads::Runs::RunStep::LastError }, nil?: true
  53. # @!attribute metadata
  54. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  55. # for storing additional information about the object in a structured format, and
  56. # querying for objects via API or the dashboard.
  57. #
  58. # Keys are strings with a maximum length of 64 characters. Values are strings with
  59. # a maximum length of 512 characters.
  60. #
  61. # @return [Hash{Symbol=>String}, nil]
  62. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  63. # @!attribute object
  64. # The object type, which is always `thread.run.step`.
  65. #
  66. # @return [Symbol, :"thread.run.step"]
  67. 1 required :object, const: :"thread.run.step"
  68. # @!attribute run_id
  69. # The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that
  70. # this run step is a part of.
  71. #
  72. # @return [String]
  73. 1 required :run_id, String
  74. # @!attribute status
  75. # The status of the run step, which can be either `in_progress`, `cancelled`,
  76. # `failed`, `completed`, or `expired`.
  77. #
  78. # @return [Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::Status]
  79. 1 required :status, enum: -> { OpenAI::Beta::Threads::Runs::RunStep::Status }
  80. # @!attribute step_details
  81. # The details of the run step.
  82. #
  83. # @return [OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails]
  84. 1 required :step_details, union: -> { OpenAI::Beta::Threads::Runs::RunStep::StepDetails }
  85. # @!attribute thread_id
  86. # The ID of the [thread](https://platform.openai.com/docs/api-reference/threads)
  87. # that was run.
  88. #
  89. # @return [String]
  90. 1 required :thread_id, String
  91. # @!attribute type
  92. # The type of run step, which can be either `message_creation` or `tool_calls`.
  93. #
  94. # @return [Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::Type]
  95. 1 required :type, enum: -> { OpenAI::Beta::Threads::Runs::RunStep::Type }
  96. # @!attribute usage
  97. # Usage statistics related to the run step. This value will be `null` while the
  98. # run step's status is `in_progress`.
  99. #
  100. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep::Usage, nil]
  101. 1 required :usage, -> { OpenAI::Beta::Threads::Runs::RunStep::Usage }, nil?: true
  102. # @!method initialize(id:, assistant_id:, cancelled_at:, completed_at:, created_at:, expired_at:, failed_at:, last_error:, metadata:, run_id:, status:, step_details:, thread_id:, type:, usage:, object: :"thread.run.step")
  103. # Some parameter documentations has been truncated, see
  104. # {OpenAI::Models::Beta::Threads::Runs::RunStep} for more details.
  105. #
  106. # Represents a step in execution of a run.
  107. #
  108. # @param id [String] The identifier of the run step, which can be referenced in API endpoints.
  109. #
  110. # @param assistant_id [String] The ID of the [assistant](https://platform.openai.com/docs/api-reference/assista
  111. #
  112. # @param cancelled_at [Integer, nil] The Unix timestamp (in seconds) for when the run step was cancelled.
  113. #
  114. # @param completed_at [Integer, nil] The Unix timestamp (in seconds) for when the run step completed.
  115. #
  116. # @param created_at [Integer] The Unix timestamp (in seconds) for when the run step was created.
  117. #
  118. # @param expired_at [Integer, nil] The Unix timestamp (in seconds) for when the run step expired. A step is conside
  119. #
  120. # @param failed_at [Integer, nil] The Unix timestamp (in seconds) for when the run step failed.
  121. #
  122. # @param last_error [OpenAI::Models::Beta::Threads::Runs::RunStep::LastError, nil] The last error associated with this run step. Will be `null` if there are no err
  123. #
  124. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  125. #
  126. # @param run_id [String] The ID of the [run](https://platform.openai.com/docs/api-reference/runs) that th
  127. #
  128. # @param status [Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::Status] The status of the run step, which can be either `in_progress`, `cancelled`, `fai
  129. #
  130. # @param step_details [OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails] The details of the run step.
  131. #
  132. # @param thread_id [String] The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) t
  133. #
  134. # @param type [Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::Type] The type of run step, which can be either `message_creation` or `tool_calls`.
  135. #
  136. # @param usage [OpenAI::Models::Beta::Threads::Runs::RunStep::Usage, nil] Usage statistics related to the run step. This value will be `null` while the ru
  137. #
  138. # @param object [Symbol, :"thread.run.step"] The object type, which is always `thread.run.step`.
  139. # @see OpenAI::Models::Beta::Threads::Runs::RunStep#last_error
  140. 1 class LastError < OpenAI::Internal::Type::BaseModel
  141. # @!attribute code
  142. # One of `server_error` or `rate_limit_exceeded`.
  143. #
  144. # @return [Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code]
  145. 1 required :code, enum: -> { OpenAI::Beta::Threads::Runs::RunStep::LastError::Code }
  146. # @!attribute message
  147. # A human-readable description of the error.
  148. #
  149. # @return [String]
  150. 1 required :message, String
  151. # @!method initialize(code:, message:)
  152. # The last error associated with this run step. Will be `null` if there are no
  153. # errors.
  154. #
  155. # @param code [Symbol, OpenAI::Models::Beta::Threads::Runs::RunStep::LastError::Code] One of `server_error` or `rate_limit_exceeded`.
  156. #
  157. # @param message [String] A human-readable description of the error.
  158. # One of `server_error` or `rate_limit_exceeded`.
  159. #
  160. # @see OpenAI::Models::Beta::Threads::Runs::RunStep::LastError#code
  161. 1 module Code
  162. 1 extend OpenAI::Internal::Type::Enum
  163. 1 SERVER_ERROR = :server_error
  164. 1 RATE_LIMIT_EXCEEDED = :rate_limit_exceeded
  165. # @!method self.values
  166. # @return [Array<Symbol>]
  167. end
  168. end
  169. # The status of the run step, which can be either `in_progress`, `cancelled`,
  170. # `failed`, `completed`, or `expired`.
  171. #
  172. # @see OpenAI::Models::Beta::Threads::Runs::RunStep#status
  173. 1 module Status
  174. 1 extend OpenAI::Internal::Type::Enum
  175. 1 IN_PROGRESS = :in_progress
  176. 1 CANCELLED = :cancelled
  177. 1 FAILED = :failed
  178. 1 COMPLETED = :completed
  179. 1 EXPIRED = :expired
  180. # @!method self.values
  181. # @return [Array<Symbol>]
  182. end
  183. # The details of the run step.
  184. #
  185. # @see OpenAI::Models::Beta::Threads::Runs::RunStep#step_details
  186. 1 module StepDetails
  187. 1 extend OpenAI::Internal::Type::Union
  188. 1 discriminator :type
  189. # Details of the message creation by the run step.
  190. 1 variant :message_creation, -> { OpenAI::Beta::Threads::Runs::MessageCreationStepDetails }
  191. # Details of the tool call.
  192. 1 variant :tool_calls, -> { OpenAI::Beta::Threads::Runs::ToolCallsStepDetails }
  193. # @!method self.variants
  194. # @return [Array(OpenAI::Models::Beta::Threads::Runs::MessageCreationStepDetails, OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails)]
  195. end
  196. # The type of run step, which can be either `message_creation` or `tool_calls`.
  197. #
  198. # @see OpenAI::Models::Beta::Threads::Runs::RunStep#type
  199. 1 module Type
  200. 1 extend OpenAI::Internal::Type::Enum
  201. 1 MESSAGE_CREATION = :message_creation
  202. 1 TOOL_CALLS = :tool_calls
  203. # @!method self.values
  204. # @return [Array<Symbol>]
  205. end
  206. # @see OpenAI::Models::Beta::Threads::Runs::RunStep#usage
  207. 1 class Usage < OpenAI::Internal::Type::BaseModel
  208. # @!attribute completion_tokens
  209. # Number of completion tokens used over the course of the run step.
  210. #
  211. # @return [Integer]
  212. 1 required :completion_tokens, Integer
  213. # @!attribute prompt_tokens
  214. # Number of prompt tokens used over the course of the run step.
  215. #
  216. # @return [Integer]
  217. 1 required :prompt_tokens, Integer
  218. # @!attribute total_tokens
  219. # Total number of tokens used (prompt + completion).
  220. #
  221. # @return [Integer]
  222. 1 required :total_tokens, Integer
  223. # @!method initialize(completion_tokens:, prompt_tokens:, total_tokens:)
  224. # Usage statistics related to the run step. This value will be `null` while the
  225. # run step's status is `in_progress`.
  226. #
  227. # @param completion_tokens [Integer] Number of completion tokens used over the course of the run step.
  228. #
  229. # @param prompt_tokens [Integer] Number of prompt tokens used over the course of the run step.
  230. #
  231. # @param total_tokens [Integer] Total number of tokens used (prompt + completion).
  232. end
  233. end
  234. end
  235. 1 RunStep = Runs::RunStep
  236. end
  237. end
  238. end
  239. end

openai-ruby/lib/openai/models/beta/threads/runs/run_step_delta.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class RunStepDelta < OpenAI::Internal::Type::BaseModel
  8. # @!attribute step_details
  9. # The details of the run step.
  10. #
  11. # @return [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject, nil]
  12. 1 optional :step_details, union: -> { OpenAI::Beta::Threads::Runs::RunStepDelta::StepDetails }
  13. # @!method initialize(step_details: nil)
  14. # The delta containing the fields that have changed on the run step.
  15. #
  16. # @param step_details [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject] The details of the run step.
  17. # The details of the run step.
  18. #
  19. # @see OpenAI::Models::Beta::Threads::Runs::RunStepDelta#step_details
  20. 1 module StepDetails
  21. 1 extend OpenAI::Internal::Type::Union
  22. 1 discriminator :type
  23. # Details of the message creation by the run step.
  24. 1 variant :message_creation, -> { OpenAI::Beta::Threads::Runs::RunStepDeltaMessageDelta }
  25. # Details of the tool call.
  26. 1 variant :tool_calls, -> { OpenAI::Beta::Threads::Runs::ToolCallDeltaObject }
  27. # @!method self.variants
  28. # @return [Array(OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta, OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject)]
  29. end
  30. end
  31. end
  32. 1 RunStepDelta = Runs::RunStepDelta
  33. end
  34. end
  35. end
  36. end

openai-ruby/lib/openai/models/beta/threads/runs/run_step_delta_event.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class RunStepDeltaEvent < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # The identifier of the run step, which can be referenced in API endpoints.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute delta
  14. # The delta containing the fields that have changed on the run step.
  15. #
  16. # @return [OpenAI::Models::Beta::Threads::Runs::RunStepDelta]
  17. 1 required :delta, -> { OpenAI::Beta::Threads::Runs::RunStepDelta }
  18. # @!attribute object
  19. # The object type, which is always `thread.run.step.delta`.
  20. #
  21. # @return [Symbol, :"thread.run.step.delta"]
  22. 1 required :object, const: :"thread.run.step.delta"
  23. # @!method initialize(id:, delta:, object: :"thread.run.step.delta")
  24. # Represents a run step delta i.e. any changed fields on a run step during
  25. # streaming.
  26. #
  27. # @param id [String] The identifier of the run step, which can be referenced in API endpoints.
  28. #
  29. # @param delta [OpenAI::Models::Beta::Threads::Runs::RunStepDelta] The delta containing the fields that have changed on the run step.
  30. #
  31. # @param object [Symbol, :"thread.run.step.delta"] The object type, which is always `thread.run.step.delta`.
  32. end
  33. end
  34. 1 RunStepDeltaEvent = Runs::RunStepDeltaEvent
  35. end
  36. end
  37. end
  38. end

openai-ruby/lib/openai/models/beta/threads/runs/run_step_delta_message_delta.rb

91.67% lines covered

100.0% branches covered

12 relevant lines. 11 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class RunStepDeltaMessageDelta < OpenAI::Internal::Type::BaseModel
  8. # @!attribute type
  9. # Always `message_creation`.
  10. #
  11. # @return [Symbol, :message_creation]
  12. 1 required :type, const: :message_creation
  13. # @!attribute message_creation
  14. #
  15. # @return [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation, nil]
  16. 1 optional :message_creation,
  17. -> {
  18. OpenAI::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation
  19. }
  20. # @!method initialize(message_creation: nil, type: :message_creation)
  21. # Details of the message creation by the run step.
  22. #
  23. # @param message_creation [OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta::MessageCreation]
  24. #
  25. # @param type [Symbol, :message_creation] Always `message_creation`.
  26. # @see OpenAI::Models::Beta::Threads::Runs::RunStepDeltaMessageDelta#message_creation
  27. 1 class MessageCreation < OpenAI::Internal::Type::BaseModel
  28. # @!attribute message_id
  29. # The ID of the message that was created by this run step.
  30. #
  31. # @return [String, nil]
  32. 1 optional :message_id, String
  33. # @!method initialize(message_id: nil)
  34. # @param message_id [String] The ID of the message that was created by this run step.
  35. end
  36. end
  37. end
  38. 1 RunStepDeltaMessageDelta = Runs::RunStepDeltaMessageDelta
  39. end
  40. end
  41. end
  42. end

openai-ruby/lib/openai/models/beta/threads/runs/run_step_include.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 module RunStepInclude
  8. 1 extend OpenAI::Internal::Type::Enum
  9. STEP_DETAILS_TOOL_CALLS_FILE_SEARCH_RESULTS_CONTENT =
  10. 1 :"step_details.tool_calls[*].file_search.results[*].content"
  11. # @!method self.values
  12. # @return [Array<Symbol>]
  13. end
  14. end
  15. 1 RunStepInclude = Runs::RunStepInclude
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/beta/threads/runs/step_list_params.rb

94.74% lines covered

100.0% branches covered

19 relevant lines. 18 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. # @see OpenAI::Resources::Beta::Threads::Runs::Steps#list
  8. 1 class StepListParams < OpenAI::Internal::Type::BaseModel
  9. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  10. 1 include OpenAI::Internal::Type::RequestParameters
  11. # @!attribute thread_id
  12. #
  13. # @return [String]
  14. 1 required :thread_id, String
  15. # @!attribute after
  16. # A cursor for use in pagination. `after` is an object ID that defines your place
  17. # in the list. For instance, if you make a list request and receive 100 objects,
  18. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  19. # fetch the next page of the list.
  20. #
  21. # @return [String, nil]
  22. 1 optional :after, String
  23. # @!attribute before
  24. # A cursor for use in pagination. `before` is an object ID that defines your place
  25. # in the list. For instance, if you make a list request and receive 100 objects,
  26. # starting with obj_foo, your subsequent call can include before=obj_foo in order
  27. # to fetch the previous page of the list.
  28. #
  29. # @return [String, nil]
  30. 1 optional :before, String
  31. # @!attribute include
  32. # A list of additional fields to include in the response. Currently the only
  33. # supported value is `step_details.tool_calls[*].file_search.results[*].content`
  34. # to fetch the file search result content.
  35. #
  36. # See the
  37. # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
  38. # for more information.
  39. #
  40. # @return [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>, nil]
  41. 1 optional :include,
  42. -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Beta::Threads::Runs::RunStepInclude] }
  43. # @!attribute limit
  44. # A limit on the number of objects to be returned. Limit can range between 1 and
  45. # 100, and the default is 20.
  46. #
  47. # @return [Integer, nil]
  48. 1 optional :limit, Integer
  49. # @!attribute order
  50. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  51. # order and `desc` for descending order.
  52. #
  53. # @return [Symbol, OpenAI::Models::Beta::Threads::Runs::StepListParams::Order, nil]
  54. 1 optional :order, enum: -> { OpenAI::Beta::Threads::Runs::StepListParams::Order }
  55. # @!method initialize(thread_id:, after: nil, before: nil, include: nil, limit: nil, order: nil, request_options: {})
  56. # Some parameter documentations has been truncated, see
  57. # {OpenAI::Models::Beta::Threads::Runs::StepListParams} for more details.
  58. #
  59. # @param thread_id [String]
  60. #
  61. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  62. #
  63. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  64. #
  65. # @param include [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>] A list of additional fields to include in the response. Currently the only suppo
  66. #
  67. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  68. #
  69. # @param order [Symbol, OpenAI::Models::Beta::Threads::Runs::StepListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  70. #
  71. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  72. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  73. # order and `desc` for descending order.
  74. 1 module Order
  75. 1 extend OpenAI::Internal::Type::Enum
  76. 1 ASC = :asc
  77. 1 DESC = :desc
  78. # @!method self.values
  79. # @return [Array<Symbol>]
  80. end
  81. end
  82. end
  83. end
  84. end
  85. end
  86. end

openai-ruby/lib/openai/models/beta/threads/runs/step_retrieve_params.rb

91.67% lines covered

100.0% branches covered

12 relevant lines. 11 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. # @see OpenAI::Resources::Beta::Threads::Runs::Steps#retrieve
  8. 1 class StepRetrieveParams < OpenAI::Internal::Type::BaseModel
  9. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  10. 1 include OpenAI::Internal::Type::RequestParameters
  11. # @!attribute thread_id
  12. #
  13. # @return [String]
  14. 1 required :thread_id, String
  15. # @!attribute run_id
  16. #
  17. # @return [String]
  18. 1 required :run_id, String
  19. # @!attribute include
  20. # A list of additional fields to include in the response. Currently the only
  21. # supported value is `step_details.tool_calls[*].file_search.results[*].content`
  22. # to fetch the file search result content.
  23. #
  24. # See the
  25. # [file search tool documentation](https://platform.openai.com/docs/assistants/tools/file-search#customizing-file-search-settings)
  26. # for more information.
  27. #
  28. # @return [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>, nil]
  29. 1 optional :include,
  30. -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Beta::Threads::Runs::RunStepInclude] }
  31. # @!method initialize(thread_id:, run_id:, include: nil, request_options: {})
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Beta::Threads::Runs::StepRetrieveParams} for more details.
  34. #
  35. # @param thread_id [String]
  36. #
  37. # @param run_id [String]
  38. #
  39. # @param include [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>] A list of additional fields to include in the response. Currently the only suppo
  40. #
  41. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  42. end
  43. end
  44. end
  45. end
  46. end
  47. end

openai-ruby/lib/openai/models/beta/threads/runs/tool_call.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. # Details of the Code Interpreter tool call the run step was involved in.
  8. 1 module ToolCall
  9. 1 extend OpenAI::Internal::Type::Union
  10. 1 discriminator :type
  11. # Details of the Code Interpreter tool call the run step was involved in.
  12. 1 variant :code_interpreter, -> { OpenAI::Beta::Threads::Runs::CodeInterpreterToolCall }
  13. 1 variant :file_search, -> { OpenAI::Beta::Threads::Runs::FileSearchToolCall }
  14. 1 variant :function, -> { OpenAI::Beta::Threads::Runs::FunctionToolCall }
  15. # @!method self.variants
  16. # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, OpenAI::Models::Beta::Threads::Runs::FunctionToolCall)]
  17. end
  18. end
  19. end
  20. end
  21. end
  22. end

openai-ruby/lib/openai/models/beta/threads/runs/tool_call_delta.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. # Details of the Code Interpreter tool call the run step was involved in.
  8. 1 module ToolCallDelta
  9. 1 extend OpenAI::Internal::Type::Union
  10. 1 discriminator :type
  11. # Details of the Code Interpreter tool call the run step was involved in.
  12. 1 variant :code_interpreter, -> { OpenAI::Beta::Threads::Runs::CodeInterpreterToolCallDelta }
  13. 1 variant :file_search, -> { OpenAI::Beta::Threads::Runs::FileSearchToolCallDelta }
  14. 1 variant :function, -> { OpenAI::Beta::Threads::Runs::FunctionToolCallDelta }
  15. # @!method self.variants
  16. # @return [Array(OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta)]
  17. end
  18. end
  19. end
  20. end
  21. end
  22. end

openai-ruby/lib/openai/models/beta/threads/runs/tool_call_delta_object.rb

88.89% lines covered

100.0% branches covered

9 relevant lines. 8 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class ToolCallDeltaObject < OpenAI::Internal::Type::BaseModel
  8. # @!attribute type
  9. # Always `tool_calls`.
  10. #
  11. # @return [Symbol, :tool_calls]
  12. 1 required :type, const: :tool_calls
  13. # @!attribute tool_calls
  14. # An array of tool calls the run step was involved in. These can be associated
  15. # with one of three types of tools: `code_interpreter`, `file_search`, or
  16. # `function`.
  17. #
  18. # @return [Array<OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta>, nil]
  19. 1 optional :tool_calls,
  20. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::Runs::ToolCallDelta] }
  21. # @!method initialize(tool_calls: nil, type: :tool_calls)
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Beta::Threads::Runs::ToolCallDeltaObject} for more details.
  24. #
  25. # Details of the tool call.
  26. #
  27. # @param tool_calls [Array<OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCallDelta, OpenAI::Models::Beta::Threads::Runs::FunctionToolCallDelta>] An array of tool calls the run step was involved in. These can be associated wit
  28. #
  29. # @param type [Symbol, :tool_calls] Always `tool_calls`.
  30. end
  31. end
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/beta/threads/runs/tool_calls_step_details.rb

88.89% lines covered

100.0% branches covered

9 relevant lines. 8 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 module Runs
  7. 1 class ToolCallsStepDetails < OpenAI::Internal::Type::BaseModel
  8. # @!attribute tool_calls
  9. # An array of tool calls the run step was involved in. These can be associated
  10. # with one of three types of tools: `code_interpreter`, `file_search`, or
  11. # `function`.
  12. #
  13. # @return [Array<OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, OpenAI::Models::Beta::Threads::Runs::FunctionToolCall>]
  14. 1 required :tool_calls,
  15. -> {
  16. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::Runs::ToolCall]
  17. }
  18. # @!attribute type
  19. # Always `tool_calls`.
  20. #
  21. # @return [Symbol, :tool_calls]
  22. 1 required :type, const: :tool_calls
  23. # @!method initialize(tool_calls:, type: :tool_calls)
  24. # Some parameter documentations has been truncated, see
  25. # {OpenAI::Models::Beta::Threads::Runs::ToolCallsStepDetails} for more details.
  26. #
  27. # Details of the tool call.
  28. #
  29. # @param tool_calls [Array<OpenAI::Models::Beta::Threads::Runs::CodeInterpreterToolCall, OpenAI::Models::Beta::Threads::Runs::FileSearchToolCall, OpenAI::Models::Beta::Threads::Runs::FunctionToolCall>] An array of tool calls the run step was involved in. These can be associated wit
  30. #
  31. # @param type [Symbol, :tool_calls] Always `tool_calls`.
  32. end
  33. end
  34. end
  35. end
  36. end
  37. end

openai-ruby/lib/openai/models/beta/threads/text.rb

87.5% lines covered

100.0% branches covered

8 relevant lines. 7 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class Text < OpenAI::Internal::Type::BaseModel
  7. # @!attribute annotations
  8. #
  9. # @return [Array<OpenAI::Models::Beta::Threads::FileCitationAnnotation, OpenAI::Models::Beta::Threads::FilePathAnnotation>]
  10. 1 required :annotations,
  11. -> {
  12. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::Annotation]
  13. }
  14. # @!attribute value
  15. # The data that makes up the text.
  16. #
  17. # @return [String]
  18. 1 required :value, String
  19. # @!method initialize(annotations:, value:)
  20. # @param annotations [Array<OpenAI::Models::Beta::Threads::FileCitationAnnotation, OpenAI::Models::Beta::Threads::FilePathAnnotation>]
  21. #
  22. # @param value [String] The data that makes up the text.
  23. end
  24. end
  25. end
  26. end
  27. end

openai-ruby/lib/openai/models/beta/threads/text_content_block.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class TextContentBlock < OpenAI::Internal::Type::BaseModel
  7. # @!attribute text
  8. #
  9. # @return [OpenAI::Models::Beta::Threads::Text]
  10. 1 required :text, -> { OpenAI::Beta::Threads::Text }
  11. # @!attribute type
  12. # Always `text`.
  13. #
  14. # @return [Symbol, :text]
  15. 1 required :type, const: :text
  16. # @!method initialize(text:, type: :text)
  17. # The text content that is part of a message.
  18. #
  19. # @param text [OpenAI::Models::Beta::Threads::Text]
  20. #
  21. # @param type [Symbol, :text] Always `text`.
  22. end
  23. end
  24. end
  25. end
  26. end

openai-ruby/lib/openai/models/beta/threads/text_content_block_param.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class TextContentBlockParam < OpenAI::Internal::Type::BaseModel
  7. # @!attribute text
  8. # Text content to be sent to the model
  9. #
  10. # @return [String]
  11. 1 required :text, String
  12. # @!attribute type
  13. # Always `text`.
  14. #
  15. # @return [Symbol, :text]
  16. 1 required :type, const: :text
  17. # @!method initialize(text:, type: :text)
  18. # The text content that is part of a message.
  19. #
  20. # @param text [String] Text content to be sent to the model
  21. #
  22. # @param type [Symbol, :text] Always `text`.
  23. end
  24. end
  25. end
  26. end
  27. end

openai-ruby/lib/openai/models/beta/threads/text_delta.rb

87.5% lines covered

100.0% branches covered

8 relevant lines. 7 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class TextDelta < OpenAI::Internal::Type::BaseModel
  7. # @!attribute annotations
  8. #
  9. # @return [Array<OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation>, nil]
  10. 1 optional :annotations,
  11. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Beta::Threads::AnnotationDelta] }
  12. # @!attribute value
  13. # The data that makes up the text.
  14. #
  15. # @return [String, nil]
  16. 1 optional :value, String
  17. # @!method initialize(annotations: nil, value: nil)
  18. # @param annotations [Array<OpenAI::Models::Beta::Threads::FileCitationDeltaAnnotation, OpenAI::Models::Beta::Threads::FilePathDeltaAnnotation>]
  19. #
  20. # @param value [String] The data that makes up the text.
  21. end
  22. end
  23. end
  24. end
  25. end

openai-ruby/lib/openai/models/beta/threads/text_delta_block.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Beta
  5. 1 module Threads
  6. 1 class TextDeltaBlock < OpenAI::Internal::Type::BaseModel
  7. # @!attribute index
  8. # The index of the content part in the message.
  9. #
  10. # @return [Integer]
  11. 1 required :index, Integer
  12. # @!attribute type
  13. # Always `text`.
  14. #
  15. # @return [Symbol, :text]
  16. 1 required :type, const: :text
  17. # @!attribute text
  18. #
  19. # @return [OpenAI::Models::Beta::Threads::TextDelta, nil]
  20. 1 optional :text, -> { OpenAI::Beta::Threads::TextDelta }
  21. # @!method initialize(index:, text: nil, type: :text)
  22. # The text content that is part of a message.
  23. #
  24. # @param index [Integer] The index of the content part in the message.
  25. #
  26. # @param text [OpenAI::Models::Beta::Threads::TextDelta]
  27. #
  28. # @param type [Symbol, :text] Always `text`.
  29. end
  30. end
  31. end
  32. end
  33. end

openai-ruby/lib/openai/models/chat/chat_completion.rb

94.59% lines covered

100.0% branches covered

37 relevant lines. 35 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # @see OpenAI::Resources::Chat::Completions#create
  6. #
  7. # @see OpenAI::Resources::Chat::Completions#stream_raw
  8. 1 class ChatCompletion < OpenAI::Internal::Type::BaseModel
  9. # @!attribute id
  10. # A unique identifier for the chat completion.
  11. #
  12. # @return [String]
  13. 1 required :id, String
  14. # @!attribute choices
  15. # A list of chat completion choices. Can be more than one if `n` is greater
  16. # than 1.
  17. #
  18. # @return [Array<OpenAI::Models::Chat::ChatCompletion::Choice>]
  19. 1 required :choices, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletion::Choice] }
  20. # @!attribute created
  21. # The Unix timestamp (in seconds) of when the chat completion was created.
  22. #
  23. # @return [Integer]
  24. 1 required :created, Integer
  25. # @!attribute model
  26. # The model used for the chat completion.
  27. #
  28. # @return [String]
  29. 1 required :model, String
  30. # @!attribute object
  31. # The object type, which is always `chat.completion`.
  32. #
  33. # @return [Symbol, :"chat.completion"]
  34. 1 required :object, const: :"chat.completion"
  35. # @!attribute service_tier
  36. # Specifies the processing type used for serving the request.
  37. #
  38. # - If set to 'auto', then the request will be processed with the service tier
  39. # configured in the Project settings. Unless otherwise configured, the Project
  40. # will use 'default'.
  41. # - If set to 'default', then the request will be processed with the standard
  42. # pricing and performance for the selected model.
  43. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  44. # 'priority', then the request will be processed with the corresponding service
  45. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  46. # Priority processing.
  47. # - When not set, the default behavior is 'auto'.
  48. #
  49. # When the `service_tier` parameter is set, the response body will include the
  50. # `service_tier` value based on the processing mode actually used to serve the
  51. # request. This response value may be different from the value set in the
  52. # parameter.
  53. #
  54. # @return [Symbol, OpenAI::Models::Chat::ChatCompletion::ServiceTier, nil]
  55. 1 optional :service_tier, enum: -> { OpenAI::Chat::ChatCompletion::ServiceTier }, nil?: true
  56. # @!attribute system_fingerprint
  57. # This fingerprint represents the backend configuration that the model runs with.
  58. #
  59. # Can be used in conjunction with the `seed` request parameter to understand when
  60. # backend changes have been made that might impact determinism.
  61. #
  62. # @return [String, nil]
  63. 1 optional :system_fingerprint, String
  64. # @!attribute usage
  65. # Usage statistics for the completion request.
  66. #
  67. # @return [OpenAI::Models::CompletionUsage, nil]
  68. 1 optional :usage, -> { OpenAI::CompletionUsage }
  69. # @!method initialize(id:, choices:, created:, model:, service_tier: nil, system_fingerprint: nil, usage: nil, object: :"chat.completion")
  70. # Some parameter documentations has been truncated, see
  71. # {OpenAI::Models::Chat::ChatCompletion} for more details.
  72. #
  73. # Represents a chat completion response returned by model, based on the provided
  74. # input.
  75. #
  76. # @param id [String] A unique identifier for the chat completion.
  77. #
  78. # @param choices [Array<OpenAI::Models::Chat::ChatCompletion::Choice>] A list of chat completion choices. Can be more than one if `n` is greater than 1
  79. #
  80. # @param created [Integer] The Unix timestamp (in seconds) of when the chat completion was created.
  81. #
  82. # @param model [String] The model used for the chat completion.
  83. #
  84. # @param service_tier [Symbol, OpenAI::Models::Chat::ChatCompletion::ServiceTier, nil] Specifies the processing type used for serving the request.
  85. #
  86. # @param system_fingerprint [String] This fingerprint represents the backend configuration that the model runs with.
  87. #
  88. # @param usage [OpenAI::Models::CompletionUsage] Usage statistics for the completion request.
  89. #
  90. # @param object [Symbol, :"chat.completion"] The object type, which is always `chat.completion`.
  91. 1 class Choice < OpenAI::Internal::Type::BaseModel
  92. # @!attribute finish_reason
  93. # The reason the model stopped generating tokens. This will be `stop` if the model
  94. # hit a natural stop point or a provided stop sequence, `length` if the maximum
  95. # number of tokens specified in the request was reached, `content_filter` if
  96. # content was omitted due to a flag from our content filters, `tool_calls` if the
  97. # model called a tool, or `function_call` (deprecated) if the model called a
  98. # function.
  99. #
  100. # @return [Symbol, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason]
  101. 1 required :finish_reason, enum: -> { OpenAI::Chat::ChatCompletion::Choice::FinishReason }
  102. # @!attribute index
  103. # The index of the choice in the list of choices.
  104. #
  105. # @return [Integer]
  106. 1 required :index, Integer
  107. # @!attribute logprobs
  108. # Log probability information for the choice.
  109. #
  110. # @return [OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs, nil]
  111. 1 required :logprobs, -> { OpenAI::Chat::ChatCompletion::Choice::Logprobs }, nil?: true
  112. # @!attribute message
  113. # A chat completion message generated by the model.
  114. #
  115. # @return [OpenAI::Models::Chat::ChatCompletionMessage]
  116. 1 required :message, -> { OpenAI::Chat::ChatCompletionMessage }
  117. # @!method initialize(finish_reason:, index:, logprobs:, message:)
  118. # Some parameter documentations has been truncated, see
  119. # {OpenAI::Models::Chat::ChatCompletion::Choice} for more details.
  120. #
  121. # @param finish_reason [Symbol, OpenAI::Models::Chat::ChatCompletion::Choice::FinishReason] The reason the model stopped generating tokens. This will be `stop` if the model
  122. #
  123. # @param index [Integer] The index of the choice in the list of choices.
  124. #
  125. # @param logprobs [OpenAI::Models::Chat::ChatCompletion::Choice::Logprobs, nil] Log probability information for the choice.
  126. #
  127. # @param message [OpenAI::Models::Chat::ChatCompletionMessage] A chat completion message generated by the model.
  128. # The reason the model stopped generating tokens. This will be `stop` if the model
  129. # hit a natural stop point or a provided stop sequence, `length` if the maximum
  130. # number of tokens specified in the request was reached, `content_filter` if
  131. # content was omitted due to a flag from our content filters, `tool_calls` if the
  132. # model called a tool, or `function_call` (deprecated) if the model called a
  133. # function.
  134. #
  135. # @see OpenAI::Models::Chat::ChatCompletion::Choice#finish_reason
  136. 1 module FinishReason
  137. 1 extend OpenAI::Internal::Type::Enum
  138. 1 STOP = :stop
  139. 1 LENGTH = :length
  140. 1 TOOL_CALLS = :tool_calls
  141. 1 CONTENT_FILTER = :content_filter
  142. 1 FUNCTION_CALL = :function_call
  143. # @!method self.values
  144. # @return [Array<Symbol>]
  145. end
  146. # @see OpenAI::Models::Chat::ChatCompletion::Choice#logprobs
  147. 1 class Logprobs < OpenAI::Internal::Type::BaseModel
  148. # @!attribute content
  149. # A list of message content tokens with log probability information.
  150. #
  151. # @return [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil]
  152. 1 required :content,
  153. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionTokenLogprob] },
  154. nil?: true
  155. # @!attribute refusal
  156. # A list of message refusal tokens with log probability information.
  157. #
  158. # @return [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil]
  159. 1 required :refusal,
  160. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionTokenLogprob] },
  161. nil?: true
  162. # @!method initialize(content:, refusal:)
  163. # Log probability information for the choice.
  164. #
  165. # @param content [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil] A list of message content tokens with log probability information.
  166. #
  167. # @param refusal [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil] A list of message refusal tokens with log probability information.
  168. end
  169. end
  170. # Specifies the processing type used for serving the request.
  171. #
  172. # - If set to 'auto', then the request will be processed with the service tier
  173. # configured in the Project settings. Unless otherwise configured, the Project
  174. # will use 'default'.
  175. # - If set to 'default', then the request will be processed with the standard
  176. # pricing and performance for the selected model.
  177. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  178. # 'priority', then the request will be processed with the corresponding service
  179. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  180. # Priority processing.
  181. # - When not set, the default behavior is 'auto'.
  182. #
  183. # When the `service_tier` parameter is set, the response body will include the
  184. # `service_tier` value based on the processing mode actually used to serve the
  185. # request. This response value may be different from the value set in the
  186. # parameter.
  187. #
  188. # @see OpenAI::Models::Chat::ChatCompletion#service_tier
  189. 1 module ServiceTier
  190. 1 extend OpenAI::Internal::Type::Enum
  191. 1 AUTO = :auto
  192. 1 DEFAULT = :default
  193. 1 FLEX = :flex
  194. 1 SCALE = :scale
  195. 1 PRIORITY = :priority
  196. # @!method self.values
  197. # @return [Array<Symbol>]
  198. end
  199. end
  200. end
  201. 1 ChatCompletion = Chat::ChatCompletion
  202. end
  203. end

openai-ruby/lib/openai/models/chat/chat_completion_assistant_message_param.rb

87.1% lines covered

100.0% branches covered

31 relevant lines. 27 lines covered and 4 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionAssistantMessageParam < OpenAI::Internal::Type::BaseModel
  6. # @!attribute role
  7. # The role of the messages author, in this case `assistant`.
  8. #
  9. # @return [Symbol, :assistant]
  10. 1 required :role, const: :assistant
  11. # @!attribute audio
  12. # Data about a previous audio response from the model.
  13. # [Learn more](https://platform.openai.com/docs/guides/audio).
  14. #
  15. # @return [OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio, nil]
  16. 1 optional :audio, -> { OpenAI::Chat::ChatCompletionAssistantMessageParam::Audio }, nil?: true
  17. # @!attribute content
  18. # The contents of the assistant message. Required unless `tool_calls` or
  19. # `function_call` is specified.
  20. #
  21. # @return [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal>, nil]
  22. 1 optional :content,
  23. union: -> {
  24. OpenAI::Chat::ChatCompletionAssistantMessageParam::Content
  25. },
  26. nil?: true
  27. # @!attribute function_call
  28. # @deprecated
  29. #
  30. # Deprecated and replaced by `tool_calls`. The name and arguments of a function
  31. # that should be called, as generated by the model.
  32. #
  33. # @return [OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall, nil]
  34. 1 optional :function_call,
  35. -> { OpenAI::Chat::ChatCompletionAssistantMessageParam::FunctionCall },
  36. nil?: true
  37. # @!attribute name
  38. # An optional name for the participant. Provides the model information to
  39. # differentiate between participants of the same role.
  40. #
  41. # @return [String, nil]
  42. 1 optional :name, String
  43. # @!attribute refusal
  44. # The refusal message by the assistant.
  45. #
  46. # @return [String, nil]
  47. 1 optional :refusal, String, nil?: true
  48. # @!attribute tool_calls
  49. # The tool calls generated by the model, such as function calls.
  50. #
  51. # @return [Array<OpenAI::Models::Chat::ChatCompletionMessageToolCall>, nil]
  52. 1 optional :tool_calls,
  53. -> {
  54. OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionMessageToolCall]
  55. }
  56. # @!method initialize(audio: nil, content: nil, function_call: nil, name: nil, refusal: nil, tool_calls: nil, role: :assistant)
  57. # Some parameter documentations has been truncated, see
  58. # {OpenAI::Models::Chat::ChatCompletionAssistantMessageParam} for more details.
  59. #
  60. # Messages sent by the model in response to user messages.
  61. #
  62. # @param audio [OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio, nil] Data about a previous audio response from the model.
  63. #
  64. # @param content [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal>, nil] The contents of the assistant message. Required unless `tool_calls` or `function
  65. #
  66. # @param function_call [OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall, nil] Deprecated and replaced by `tool_calls`. The name and arguments of a function th
  67. #
  68. # @param name [String] An optional name for the participant. Provides the model information to differen
  69. #
  70. # @param refusal [String, nil] The refusal message by the assistant.
  71. #
  72. # @param tool_calls [Array<OpenAI::Models::Chat::ChatCompletionMessageToolCall>] The tool calls generated by the model, such as function calls.
  73. #
  74. # @param role [Symbol, :assistant] The role of the messages author, in this case `assistant`.
  75. # @see OpenAI::Models::Chat::ChatCompletionAssistantMessageParam#audio
  76. 1 class Audio < OpenAI::Internal::Type::BaseModel
  77. # @!attribute id
  78. # Unique identifier for a previous audio response from the model.
  79. #
  80. # @return [String]
  81. 1 required :id, String
  82. # @!method initialize(id:)
  83. # Some parameter documentations has been truncated, see
  84. # {OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Audio} for more
  85. # details.
  86. #
  87. # Data about a previous audio response from the model.
  88. # [Learn more](https://platform.openai.com/docs/guides/audio).
  89. #
  90. # @param id [String] Unique identifier for a previous audio response from the model.
  91. end
  92. # The contents of the assistant message. Required unless `tool_calls` or
  93. # `function_call` is specified.
  94. #
  95. # @see OpenAI::Models::Chat::ChatCompletionAssistantMessageParam#content
  96. 1 module Content
  97. 1 extend OpenAI::Internal::Type::Union
  98. # The contents of the assistant message.
  99. 1 variant String
  100. # An array of content parts with a defined type. Can be one or more of type `text`, or exactly one of type `refusal`.
  101. 1 variant -> { OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPartArray }
  102. # Learn about
  103. # [text inputs](https://platform.openai.com/docs/guides/text-generation).
  104. 1 module ArrayOfContentPart
  105. 1 extend OpenAI::Internal::Type::Union
  106. 1 discriminator :type
  107. # Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
  108. 1 variant :text, -> { OpenAI::Chat::ChatCompletionContentPartText }
  109. 1 variant :refusal, -> { OpenAI::Chat::ChatCompletionContentPartRefusal }
  110. # @!method self.variants
  111. # @return [Array(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal)]
  112. end
  113. # @!method self.variants
  114. # @return [Array(String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartRefusal>)]
  115. # @type [OpenAI::Internal::Type::Converter]
  116. ArrayOfContentPartArray =
  117. 1 OpenAI::Internal::Type::ArrayOf[union: -> {
  118. OpenAI::Chat::ChatCompletionAssistantMessageParam::Content::ArrayOfContentPart
  119. }]
  120. end
  121. # @deprecated
  122. #
  123. # @see OpenAI::Models::Chat::ChatCompletionAssistantMessageParam#function_call
  124. 1 class FunctionCall < OpenAI::Internal::Type::BaseModel
  125. # @!attribute arguments
  126. # The arguments to call the function with, as generated by the model in JSON
  127. # format. Note that the model does not always generate valid JSON, and may
  128. # hallucinate parameters not defined by your function schema. Validate the
  129. # arguments in your code before calling your function.
  130. #
  131. # @return [String]
  132. 1 required :arguments, String
  133. # @!attribute name
  134. # The name of the function to call.
  135. #
  136. # @return [String]
  137. 1 required :name, String
  138. # @!method initialize(arguments:, name:)
  139. # Some parameter documentations has been truncated, see
  140. # {OpenAI::Models::Chat::ChatCompletionAssistantMessageParam::FunctionCall} for
  141. # more details.
  142. #
  143. # Deprecated and replaced by `tool_calls`. The name and arguments of a function
  144. # that should be called, as generated by the model.
  145. #
  146. # @param arguments [String] The arguments to call the function with, as generated by the model in JSON forma
  147. #
  148. # @param name [String] The name of the function to call.
  149. end
  150. end
  151. end
  152. 1 ChatCompletionAssistantMessageParam = Chat::ChatCompletionAssistantMessageParam
  153. end
  154. end

openai-ruby/lib/openai/models/chat/chat_completion_audio.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionAudio < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # Unique identifier for this audio response.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute data
  12. # Base64 encoded audio bytes generated by the model, in the format specified in
  13. # the request.
  14. #
  15. # @return [String]
  16. 1 required :data, String
  17. # @!attribute expires_at
  18. # The Unix timestamp (in seconds) for when this audio response will no longer be
  19. # accessible on the server for use in multi-turn conversations.
  20. #
  21. # @return [Integer]
  22. 1 required :expires_at, Integer
  23. # @!attribute transcript
  24. # Transcript of the audio generated by the model.
  25. #
  26. # @return [String]
  27. 1 required :transcript, String
  28. # @!method initialize(id:, data:, expires_at:, transcript:)
  29. # Some parameter documentations has been truncated, see
  30. # {OpenAI::Models::Chat::ChatCompletionAudio} for more details.
  31. #
  32. # If the audio output modality is requested, this object contains data about the
  33. # audio response from the model.
  34. # [Learn more](https://platform.openai.com/docs/guides/audio).
  35. #
  36. # @param id [String] Unique identifier for this audio response.
  37. #
  38. # @param data [String] Base64 encoded audio bytes generated by the model, in the format
  39. #
  40. # @param expires_at [Integer] The Unix timestamp (in seconds) for when this audio response will
  41. #
  42. # @param transcript [String] Transcript of the audio generated by the model.
  43. end
  44. end
  45. 1 ChatCompletionAudio = Chat::ChatCompletionAudio
  46. end
  47. end

openai-ruby/lib/openai/models/chat/chat_completion_audio_param.rb

97.22% lines covered

100.0% branches covered

36 relevant lines. 35 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionAudioParam < OpenAI::Internal::Type::BaseModel
  6. # @!attribute format_
  7. # Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`,
  8. # or `pcm16`.
  9. #
  10. # @return [Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Format]
  11. 1 required :format_, enum: -> { OpenAI::Chat::ChatCompletionAudioParam::Format }, api_name: :format
  12. # @!attribute voice
  13. # The voice the model uses to respond. Supported voices are `alloy`, `ash`,
  14. # `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, and `shimmer`.
  15. #
  16. # @return [String, Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice]
  17. 1 required :voice, union: -> { OpenAI::Chat::ChatCompletionAudioParam::Voice }
  18. # @!method initialize(format_:, voice:)
  19. # Some parameter documentations has been truncated, see
  20. # {OpenAI::Models::Chat::ChatCompletionAudioParam} for more details.
  21. #
  22. # Parameters for audio output. Required when audio output is requested with
  23. # `modalities: ["audio"]`.
  24. # [Learn more](https://platform.openai.com/docs/guides/audio).
  25. #
  26. # @param format_ [Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Format] Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`,
  27. #
  28. # @param voice [String, Symbol, OpenAI::Models::Chat::ChatCompletionAudioParam::Voice] The voice the model uses to respond. Supported voices are
  29. # Specifies the output audio format. Must be one of `wav`, `mp3`, `flac`, `opus`,
  30. # or `pcm16`.
  31. #
  32. # @see OpenAI::Models::Chat::ChatCompletionAudioParam#format_
  33. 1 module Format
  34. 1 extend OpenAI::Internal::Type::Enum
  35. 1 WAV = :wav
  36. 1 AAC = :aac
  37. 1 MP3 = :mp3
  38. 1 FLAC = :flac
  39. 1 OPUS = :opus
  40. 1 PCM16 = :pcm16
  41. # @!method self.values
  42. # @return [Array<Symbol>]
  43. end
  44. # The voice the model uses to respond. Supported voices are `alloy`, `ash`,
  45. # `ballad`, `coral`, `echo`, `fable`, `nova`, `onyx`, `sage`, and `shimmer`.
  46. #
  47. # @see OpenAI::Models::Chat::ChatCompletionAudioParam#voice
  48. 1 module Voice
  49. 1 extend OpenAI::Internal::Type::Union
  50. 1 variant String
  51. 1 variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::ALLOY }
  52. 1 variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::ASH }
  53. 1 variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::BALLAD }
  54. 1 variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::CORAL }
  55. 1 variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::ECHO }
  56. 1 variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::SAGE }
  57. 1 variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::SHIMMER }
  58. 1 variant const: -> { OpenAI::Models::Chat::ChatCompletionAudioParam::Voice::VERSE }
  59. # @!method self.variants
  60. # @return [Array(String, Symbol)]
  61. 1 define_sorbet_constant!(:Variants) do
  62. T.type_alias { T.any(String, OpenAI::Chat::ChatCompletionAudioParam::Voice::TaggedSymbol) }
  63. end
  64. # @!group
  65. 1 ALLOY = :alloy
  66. 1 ASH = :ash
  67. 1 BALLAD = :ballad
  68. 1 CORAL = :coral
  69. 1 ECHO = :echo
  70. 1 SAGE = :sage
  71. 1 SHIMMER = :shimmer
  72. 1 VERSE = :verse
  73. # @!endgroup
  74. end
  75. end
  76. end
  77. 1 ChatCompletionAudioParam = Chat::ChatCompletionAudioParam
  78. end
  79. end

openai-ruby/lib/openai/models/chat/chat_completion_chunk.rb

93.94% lines covered

100.0% branches covered

66 relevant lines. 62 lines covered and 4 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionChunk < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # A unique identifier for the chat completion. Each chunk has the same ID.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute choices
  12. # A list of chat completion choices. Can contain more than one elements if `n` is
  13. # greater than 1. Can also be empty for the last chunk if you set
  14. # `stream_options: {"include_usage": true}`.
  15. #
  16. # @return [Array<OpenAI::Models::Chat::ChatCompletionChunk::Choice>]
  17. 1 required :choices, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionChunk::Choice] }
  18. # @!attribute created
  19. # The Unix timestamp (in seconds) of when the chat completion was created. Each
  20. # chunk has the same timestamp.
  21. #
  22. # @return [Integer]
  23. 1 required :created, Integer
  24. # @!attribute model
  25. # The model to generate the completion.
  26. #
  27. # @return [String]
  28. 1 required :model, String
  29. # @!attribute object
  30. # The object type, which is always `chat.completion.chunk`.
  31. #
  32. # @return [Symbol, :"chat.completion.chunk"]
  33. 1 required :object, const: :"chat.completion.chunk"
  34. # @!attribute service_tier
  35. # Specifies the processing type used for serving the request.
  36. #
  37. # - If set to 'auto', then the request will be processed with the service tier
  38. # configured in the Project settings. Unless otherwise configured, the Project
  39. # will use 'default'.
  40. # - If set to 'default', then the request will be processed with the standard
  41. # pricing and performance for the selected model.
  42. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  43. # 'priority', then the request will be processed with the corresponding service
  44. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  45. # Priority processing.
  46. # - When not set, the default behavior is 'auto'.
  47. #
  48. # When the `service_tier` parameter is set, the response body will include the
  49. # `service_tier` value based on the processing mode actually used to serve the
  50. # request. This response value may be different from the value set in the
  51. # parameter.
  52. #
  53. # @return [Symbol, OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier, nil]
  54. 1 optional :service_tier, enum: -> { OpenAI::Chat::ChatCompletionChunk::ServiceTier }, nil?: true
  55. # @!attribute system_fingerprint
  56. # This fingerprint represents the backend configuration that the model runs with.
  57. # Can be used in conjunction with the `seed` request parameter to understand when
  58. # backend changes have been made that might impact determinism.
  59. #
  60. # @return [String, nil]
  61. 1 optional :system_fingerprint, String
  62. # @!attribute usage
  63. # An optional field that will only be present when you set
  64. # `stream_options: {"include_usage": true}` in your request. When present, it
  65. # contains a null value **except for the last chunk** which contains the token
  66. # usage statistics for the entire request.
  67. #
  68. # **NOTE:** If the stream is interrupted or cancelled, you may not receive the
  69. # final usage chunk which contains the total token usage for the request.
  70. #
  71. # @return [OpenAI::Models::CompletionUsage, nil]
  72. 1 optional :usage, -> { OpenAI::CompletionUsage }, nil?: true
  73. # @!method initialize(id:, choices:, created:, model:, service_tier: nil, system_fingerprint: nil, usage: nil, object: :"chat.completion.chunk")
  74. # Some parameter documentations has been truncated, see
  75. # {OpenAI::Models::Chat::ChatCompletionChunk} for more details.
  76. #
  77. # Represents a streamed chunk of a chat completion response returned by the model,
  78. # based on the provided input.
  79. # [Learn more](https://platform.openai.com/docs/guides/streaming-responses).
  80. #
  81. # @param id [String] A unique identifier for the chat completion. Each chunk has the same ID.
  82. #
  83. # @param choices [Array<OpenAI::Models::Chat::ChatCompletionChunk::Choice>] A list of chat completion choices. Can contain more than one elements if `n` is
  84. #
  85. # @param created [Integer] The Unix timestamp (in seconds) of when the chat completion was created. Each ch
  86. #
  87. # @param model [String] The model to generate the completion.
  88. #
  89. # @param service_tier [Symbol, OpenAI::Models::Chat::ChatCompletionChunk::ServiceTier, nil] Specifies the processing type used for serving the request.
  90. #
  91. # @param system_fingerprint [String] This fingerprint represents the backend configuration that the model runs with.
  92. #
  93. # @param usage [OpenAI::Models::CompletionUsage, nil] An optional field that will only be present when you set
  94. #
  95. # @param object [Symbol, :"chat.completion.chunk"] The object type, which is always `chat.completion.chunk`.
  96. 1 class Choice < OpenAI::Internal::Type::BaseModel
  97. # @!attribute delta
  98. # A chat completion delta generated by streamed model responses.
  99. #
  100. # @return [OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta]
  101. 1 required :delta, -> { OpenAI::Chat::ChatCompletionChunk::Choice::Delta }
  102. # @!attribute finish_reason
  103. # The reason the model stopped generating tokens. This will be `stop` if the model
  104. # hit a natural stop point or a provided stop sequence, `length` if the maximum
  105. # number of tokens specified in the request was reached, `content_filter` if
  106. # content was omitted due to a flag from our content filters, `tool_calls` if the
  107. # model called a tool, or `function_call` (deprecated) if the model called a
  108. # function.
  109. #
  110. # @return [Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason, nil]
  111. 1 required :finish_reason,
  112. enum: -> {
  113. OpenAI::Chat::ChatCompletionChunk::Choice::FinishReason
  114. },
  115. nil?: true
  116. # @!attribute index
  117. # The index of the choice in the list of choices.
  118. #
  119. # @return [Integer]
  120. 1 required :index, Integer
  121. # @!attribute logprobs
  122. # Log probability information for the choice.
  123. #
  124. # @return [OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs, nil]
  125. 1 optional :logprobs, -> { OpenAI::Chat::ChatCompletionChunk::Choice::Logprobs }, nil?: true
  126. # @!method initialize(delta:, finish_reason:, index:, logprobs: nil)
  127. # Some parameter documentations has been truncated, see
  128. # {OpenAI::Models::Chat::ChatCompletionChunk::Choice} for more details.
  129. #
  130. # @param delta [OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta] A chat completion delta generated by streamed model responses.
  131. #
  132. # @param finish_reason [Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::FinishReason, nil] The reason the model stopped generating tokens. This will be `stop` if the model
  133. #
  134. # @param index [Integer] The index of the choice in the list of choices.
  135. #
  136. # @param logprobs [OpenAI::Models::Chat::ChatCompletionChunk::Choice::Logprobs, nil] Log probability information for the choice.
  137. # @see OpenAI::Models::Chat::ChatCompletionChunk::Choice#delta
  138. 1 class Delta < OpenAI::Internal::Type::BaseModel
  139. # @!attribute content
  140. # The contents of the chunk message.
  141. #
  142. # @return [String, nil]
  143. 1 optional :content, String, nil?: true
  144. # @!attribute function_call
  145. # @deprecated
  146. #
  147. # Deprecated and replaced by `tool_calls`. The name and arguments of a function
  148. # that should be called, as generated by the model.
  149. #
  150. # @return [OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall, nil]
  151. 1 optional :function_call, -> { OpenAI::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall }
  152. # @!attribute refusal
  153. # The refusal message generated by the model.
  154. #
  155. # @return [String, nil]
  156. 1 optional :refusal, String, nil?: true
  157. # @!attribute role
  158. # The role of the author of this message.
  159. #
  160. # @return [Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role, nil]
  161. 1 optional :role, enum: -> { OpenAI::Chat::ChatCompletionChunk::Choice::Delta::Role }
  162. # @!attribute tool_calls
  163. #
  164. # @return [Array<OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall>, nil]
  165. 1 optional :tool_calls,
  166. -> {
  167. OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionChunk::Choice::Delta::ToolCall]
  168. }
  169. # @!method initialize(content: nil, function_call: nil, refusal: nil, role: nil, tool_calls: nil)
  170. # Some parameter documentations has been truncated, see
  171. # {OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta} for more details.
  172. #
  173. # A chat completion delta generated by streamed model responses.
  174. #
  175. # @param content [String, nil] The contents of the chunk message.
  176. #
  177. # @param function_call [OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall] Deprecated and replaced by `tool_calls`. The name and arguments of a function th
  178. #
  179. # @param refusal [String, nil] The refusal message generated by the model.
  180. #
  181. # @param role [Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::Role] The role of the author of this message.
  182. #
  183. # @param tool_calls [Array<OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall>]
  184. # @deprecated
  185. #
  186. # @see OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta#function_call
  187. 1 class FunctionCall < OpenAI::Internal::Type::BaseModel
  188. # @!attribute arguments
  189. # The arguments to call the function with, as generated by the model in JSON
  190. # format. Note that the model does not always generate valid JSON, and may
  191. # hallucinate parameters not defined by your function schema. Validate the
  192. # arguments in your code before calling your function.
  193. #
  194. # @return [String, nil]
  195. 1 optional :arguments, String
  196. # @!attribute name
  197. # The name of the function to call.
  198. #
  199. # @return [String, nil]
  200. 1 optional :name, String
  201. # @!method initialize(arguments: nil, name: nil)
  202. # Some parameter documentations has been truncated, see
  203. # {OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::FunctionCall} for
  204. # more details.
  205. #
  206. # Deprecated and replaced by `tool_calls`. The name and arguments of a function
  207. # that should be called, as generated by the model.
  208. #
  209. # @param arguments [String] The arguments to call the function with, as generated by the model in JSON forma
  210. #
  211. # @param name [String] The name of the function to call.
  212. end
  213. # The role of the author of this message.
  214. #
  215. # @see OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta#role
  216. 1 module Role
  217. 1 extend OpenAI::Internal::Type::Enum
  218. 1 DEVELOPER = :developer
  219. 1 SYSTEM = :system
  220. 1 USER = :user
  221. 1 ASSISTANT = :assistant
  222. 1 TOOL = :tool
  223. # @!method self.values
  224. # @return [Array<Symbol>]
  225. end
  226. 1 class ToolCall < OpenAI::Internal::Type::BaseModel
  227. # @!attribute index
  228. #
  229. # @return [Integer]
  230. 1 required :index, Integer
  231. # @!attribute id
  232. # The ID of the tool call.
  233. #
  234. # @return [String, nil]
  235. 1 optional :id, String
  236. # @!attribute function
  237. #
  238. # @return [OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function, nil]
  239. 1 optional :function, -> { OpenAI::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function }
  240. # @!attribute type
  241. # The type of the tool. Currently, only `function` is supported.
  242. #
  243. # @return [Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type, nil]
  244. 1 optional :type, enum: -> { OpenAI::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type }
  245. # @!method initialize(index:, id: nil, function: nil, type: nil)
  246. # @param index [Integer]
  247. #
  248. # @param id [String] The ID of the tool call.
  249. #
  250. # @param function [OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function]
  251. #
  252. # @param type [Symbol, OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Type] The type of the tool. Currently, only `function` is supported.
  253. # @see OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall#function
  254. 1 class Function < OpenAI::Internal::Type::BaseModel
  255. # @!attribute arguments
  256. # The arguments to call the function with, as generated by the model in JSON
  257. # format. Note that the model does not always generate valid JSON, and may
  258. # hallucinate parameters not defined by your function schema. Validate the
  259. # arguments in your code before calling your function.
  260. #
  261. # @return [String, nil]
  262. 1 optional :arguments, String
  263. # @!attribute name
  264. # The name of the function to call.
  265. #
  266. # @return [String, nil]
  267. 1 optional :name, String
  268. # @!method initialize(arguments: nil, name: nil)
  269. # Some parameter documentations has been truncated, see
  270. # {OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall::Function}
  271. # for more details.
  272. #
  273. # @param arguments [String] The arguments to call the function with, as generated by the model in JSON forma
  274. #
  275. # @param name [String] The name of the function to call.
  276. end
  277. # The type of the tool. Currently, only `function` is supported.
  278. #
  279. # @see OpenAI::Models::Chat::ChatCompletionChunk::Choice::Delta::ToolCall#type
  280. 1 module Type
  281. 1 extend OpenAI::Internal::Type::Enum
  282. 1 FUNCTION = :function
  283. # @!method self.values
  284. # @return [Array<Symbol>]
  285. end
  286. end
  287. end
  288. # The reason the model stopped generating tokens. This will be `stop` if the model
  289. # hit a natural stop point or a provided stop sequence, `length` if the maximum
  290. # number of tokens specified in the request was reached, `content_filter` if
  291. # content was omitted due to a flag from our content filters, `tool_calls` if the
  292. # model called a tool, or `function_call` (deprecated) if the model called a
  293. # function.
  294. #
  295. # @see OpenAI::Models::Chat::ChatCompletionChunk::Choice#finish_reason
  296. 1 module FinishReason
  297. 1 extend OpenAI::Internal::Type::Enum
  298. 1 STOP = :stop
  299. 1 LENGTH = :length
  300. 1 TOOL_CALLS = :tool_calls
  301. 1 CONTENT_FILTER = :content_filter
  302. 1 FUNCTION_CALL = :function_call
  303. # @!method self.values
  304. # @return [Array<Symbol>]
  305. end
  306. # @see OpenAI::Models::Chat::ChatCompletionChunk::Choice#logprobs
  307. 1 class Logprobs < OpenAI::Internal::Type::BaseModel
  308. # @!attribute content
  309. # A list of message content tokens with log probability information.
  310. #
  311. # @return [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil]
  312. 1 required :content,
  313. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionTokenLogprob] },
  314. nil?: true
  315. # @!attribute refusal
  316. # A list of message refusal tokens with log probability information.
  317. #
  318. # @return [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil]
  319. 1 required :refusal,
  320. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionTokenLogprob] },
  321. nil?: true
  322. # @!method initialize(content:, refusal:)
  323. # Log probability information for the choice.
  324. #
  325. # @param content [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil] A list of message content tokens with log probability information.
  326. #
  327. # @param refusal [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob>, nil] A list of message refusal tokens with log probability information.
  328. end
  329. end
  330. # Specifies the processing type used for serving the request.
  331. #
  332. # - If set to 'auto', then the request will be processed with the service tier
  333. # configured in the Project settings. Unless otherwise configured, the Project
  334. # will use 'default'.
  335. # - If set to 'default', then the request will be processed with the standard
  336. # pricing and performance for the selected model.
  337. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  338. # 'priority', then the request will be processed with the corresponding service
  339. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  340. # Priority processing.
  341. # - When not set, the default behavior is 'auto'.
  342. #
  343. # When the `service_tier` parameter is set, the response body will include the
  344. # `service_tier` value based on the processing mode actually used to serve the
  345. # request. This response value may be different from the value set in the
  346. # parameter.
  347. #
  348. # @see OpenAI::Models::Chat::ChatCompletionChunk#service_tier
  349. 1 module ServiceTier
  350. 1 extend OpenAI::Internal::Type::Enum
  351. 1 AUTO = :auto
  352. 1 DEFAULT = :default
  353. 1 FLEX = :flex
  354. 1 SCALE = :scale
  355. 1 PRIORITY = :priority
  356. # @!method self.values
  357. # @return [Array<Symbol>]
  358. end
  359. end
  360. end
  361. 1 ChatCompletionChunk = Chat::ChatCompletionChunk
  362. end
  363. end

openai-ruby/lib/openai/models/chat/chat_completion_content_part.rb

100.0% lines covered

100.0% branches covered

18 relevant lines. 18 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # Learn about
  6. # [text inputs](https://platform.openai.com/docs/guides/text-generation).
  7. 1 module ChatCompletionContentPart
  8. 1 extend OpenAI::Internal::Type::Union
  9. 1 discriminator :type
  10. # Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
  11. 1 variant :text, -> { OpenAI::Chat::ChatCompletionContentPartText }
  12. # Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
  13. 1 variant :image_url, -> { OpenAI::Chat::ChatCompletionContentPartImage }
  14. # Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).
  15. 1 variant :input_audio, -> { OpenAI::Chat::ChatCompletionContentPartInputAudio }
  16. # Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text generation.
  17. 1 variant :file, -> { OpenAI::Chat::ChatCompletionContentPart::File }
  18. 1 class File < OpenAI::Internal::Type::BaseModel
  19. # @!attribute file
  20. #
  21. # @return [OpenAI::Models::Chat::ChatCompletionContentPart::File::File]
  22. 1 required :file, -> { OpenAI::Chat::ChatCompletionContentPart::File::File }
  23. # @!attribute type
  24. # The type of the content part. Always `file`.
  25. #
  26. # @return [Symbol, :file]
  27. 1 required :type, const: :file
  28. # @!method initialize(file:, type: :file)
  29. # Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text
  30. # generation.
  31. #
  32. # @param file [OpenAI::Models::Chat::ChatCompletionContentPart::File::File]
  33. #
  34. # @param type [Symbol, :file] The type of the content part. Always `file`.
  35. # @see OpenAI::Models::Chat::ChatCompletionContentPart::File#file
  36. 1 class File < OpenAI::Internal::Type::BaseModel
  37. # @!attribute file_data
  38. # The base64 encoded file data, used when passing the file to the model as a
  39. # string.
  40. #
  41. # @return [String, nil]
  42. 1 optional :file_data, String
  43. # @!attribute file_id
  44. # The ID of an uploaded file to use as input.
  45. #
  46. # @return [String, nil]
  47. 1 optional :file_id, String
  48. # @!attribute filename
  49. # The name of the file, used when passing the file to the model as a string.
  50. #
  51. # @return [String, nil]
  52. 1 optional :filename, String
  53. # @!method initialize(file_data: nil, file_id: nil, filename: nil)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Chat::ChatCompletionContentPart::File::File} for more details.
  56. #
  57. # @param file_data [String] The base64 encoded file data, used when passing the file to the model
  58. #
  59. # @param file_id [String] The ID of an uploaded file to use as input.
  60. #
  61. # @param filename [String] The name of the file, used when passing the file to the model as a
  62. end
  63. end
  64. # @!method self.variants
  65. # @return [Array(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File)]
  66. end
  67. end
  68. 1 ChatCompletionContentPart = Chat::ChatCompletionContentPart
  69. end
  70. end

openai-ruby/lib/openai/models/chat/chat_completion_content_part_image.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionContentPartImage < OpenAI::Internal::Type::BaseModel
  6. # @!attribute image_url
  7. #
  8. # @return [OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL]
  9. 1 required :image_url, -> { OpenAI::Chat::ChatCompletionContentPartImage::ImageURL }
  10. # @!attribute type
  11. # The type of the content part.
  12. #
  13. # @return [Symbol, :image_url]
  14. 1 required :type, const: :image_url
  15. # @!method initialize(image_url:, type: :image_url)
  16. # Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
  17. #
  18. # @param image_url [OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL]
  19. #
  20. # @param type [Symbol, :image_url] The type of the content part.
  21. # @see OpenAI::Models::Chat::ChatCompletionContentPartImage#image_url
  22. 1 class ImageURL < OpenAI::Internal::Type::BaseModel
  23. # @!attribute url
  24. # Either a URL of the image or the base64 encoded image data.
  25. #
  26. # @return [String]
  27. 1 required :url, String
  28. # @!attribute detail
  29. # Specifies the detail level of the image. Learn more in the
  30. # [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
  31. #
  32. # @return [Symbol, OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail, nil]
  33. 1 optional :detail, enum: -> { OpenAI::Chat::ChatCompletionContentPartImage::ImageURL::Detail }
  34. # @!method initialize(url:, detail: nil)
  35. # Some parameter documentations has been truncated, see
  36. # {OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL} for more
  37. # details.
  38. #
  39. # @param url [String] Either a URL of the image or the base64 encoded image data.
  40. #
  41. # @param detail [Symbol, OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL::Detail] Specifies the detail level of the image. Learn more in the [Vision guide](https:
  42. # Specifies the detail level of the image. Learn more in the
  43. # [Vision guide](https://platform.openai.com/docs/guides/vision#low-or-high-fidelity-image-understanding).
  44. #
  45. # @see OpenAI::Models::Chat::ChatCompletionContentPartImage::ImageURL#detail
  46. 1 module Detail
  47. 1 extend OpenAI::Internal::Type::Enum
  48. 1 AUTO = :auto
  49. 1 LOW = :low
  50. 1 HIGH = :high
  51. # @!method self.values
  52. # @return [Array<Symbol>]
  53. end
  54. end
  55. end
  56. end
  57. 1 ChatCompletionContentPartImage = Chat::ChatCompletionContentPartImage
  58. end
  59. end

openai-ruby/lib/openai/models/chat/chat_completion_content_part_input_audio.rb

93.33% lines covered

100.0% branches covered

15 relevant lines. 14 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionContentPartInputAudio < OpenAI::Internal::Type::BaseModel
  6. # @!attribute input_audio
  7. #
  8. # @return [OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio]
  9. 1 required :input_audio, -> { OpenAI::Chat::ChatCompletionContentPartInputAudio::InputAudio }
  10. # @!attribute type
  11. # The type of the content part. Always `input_audio`.
  12. #
  13. # @return [Symbol, :input_audio]
  14. 1 required :type, const: :input_audio
  15. # @!method initialize(input_audio:, type: :input_audio)
  16. # Learn about [audio inputs](https://platform.openai.com/docs/guides/audio).
  17. #
  18. # @param input_audio [OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio]
  19. #
  20. # @param type [Symbol, :input_audio] The type of the content part. Always `input_audio`.
  21. # @see OpenAI::Models::Chat::ChatCompletionContentPartInputAudio#input_audio
  22. 1 class InputAudio < OpenAI::Internal::Type::BaseModel
  23. # @!attribute data
  24. # Base64 encoded audio data.
  25. #
  26. # @return [String]
  27. 1 required :data, String
  28. # @!attribute format_
  29. # The format of the encoded audio data. Currently supports "wav" and "mp3".
  30. #
  31. # @return [Symbol, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format]
  32. 1 required :format_,
  33. enum: -> { OpenAI::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format },
  34. api_name: :format
  35. # @!method initialize(data:, format_:)
  36. # Some parameter documentations has been truncated, see
  37. # {OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio} for more
  38. # details.
  39. #
  40. # @param data [String] Base64 encoded audio data.
  41. #
  42. # @param format_ [Symbol, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio::Format] The format of the encoded audio data. Currently supports "wav" and "mp3".
  43. # The format of the encoded audio data. Currently supports "wav" and "mp3".
  44. #
  45. # @see OpenAI::Models::Chat::ChatCompletionContentPartInputAudio::InputAudio#format_
  46. 1 module Format
  47. 1 extend OpenAI::Internal::Type::Enum
  48. 1 WAV = :wav
  49. 1 MP3 = :mp3
  50. # @!method self.values
  51. # @return [Array<Symbol>]
  52. end
  53. end
  54. end
  55. end
  56. 1 ChatCompletionContentPartInputAudio = Chat::ChatCompletionContentPartInputAudio
  57. end
  58. end

openai-ruby/lib/openai/models/chat/chat_completion_content_part_refusal.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionContentPartRefusal < OpenAI::Internal::Type::BaseModel
  6. # @!attribute refusal
  7. # The refusal message generated by the model.
  8. #
  9. # @return [String]
  10. 1 required :refusal, String
  11. # @!attribute type
  12. # The type of the content part.
  13. #
  14. # @return [Symbol, :refusal]
  15. 1 required :type, const: :refusal
  16. # @!method initialize(refusal:, type: :refusal)
  17. # @param refusal [String] The refusal message generated by the model.
  18. #
  19. # @param type [Symbol, :refusal] The type of the content part.
  20. end
  21. end
  22. 1 ChatCompletionContentPartRefusal = Chat::ChatCompletionContentPartRefusal
  23. end
  24. end

openai-ruby/lib/openai/models/chat/chat_completion_content_part_text.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionContentPartText < OpenAI::Internal::Type::BaseModel
  6. # @!attribute text
  7. # The text content.
  8. #
  9. # @return [String]
  10. 1 required :text, String
  11. # @!attribute type
  12. # The type of the content part.
  13. #
  14. # @return [Symbol, :text]
  15. 1 required :type, const: :text
  16. # @!method initialize(text:, type: :text)
  17. # Learn about
  18. # [text inputs](https://platform.openai.com/docs/guides/text-generation).
  19. #
  20. # @param text [String] The text content.
  21. #
  22. # @param type [Symbol, :text] The type of the content part.
  23. end
  24. end
  25. 1 ChatCompletionContentPartText = Chat::ChatCompletionContentPartText
  26. end
  27. end

openai-ruby/lib/openai/models/chat/chat_completion_deleted.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # @see OpenAI::Resources::Chat::Completions#delete
  6. 1 class ChatCompletionDeleted < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The ID of the chat completion that was deleted.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute deleted
  13. # Whether the chat completion was deleted.
  14. #
  15. # @return [Boolean]
  16. 1 required :deleted, OpenAI::Internal::Type::Boolean
  17. # @!attribute object
  18. # The type of object being deleted.
  19. #
  20. # @return [Symbol, :"chat.completion.deleted"]
  21. 1 required :object, const: :"chat.completion.deleted"
  22. # @!method initialize(id:, deleted:, object: :"chat.completion.deleted")
  23. # @param id [String] The ID of the chat completion that was deleted.
  24. #
  25. # @param deleted [Boolean] Whether the chat completion was deleted.
  26. #
  27. # @param object [Symbol, :"chat.completion.deleted"] The type of object being deleted.
  28. end
  29. end
  30. 1 ChatCompletionDeleted = Chat::ChatCompletionDeleted
  31. end
  32. end

openai-ruby/lib/openai/models/chat/chat_completion_developer_message_param.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionDeveloperMessageParam < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content
  7. # The contents of the developer message.
  8. #
  9. # @return [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>]
  10. 1 required :content, union: -> { OpenAI::Chat::ChatCompletionDeveloperMessageParam::Content }
  11. # @!attribute role
  12. # The role of the messages author, in this case `developer`.
  13. #
  14. # @return [Symbol, :developer]
  15. 1 required :role, const: :developer
  16. # @!attribute name
  17. # An optional name for the participant. Provides the model information to
  18. # differentiate between participants of the same role.
  19. #
  20. # @return [String, nil]
  21. 1 optional :name, String
  22. # @!method initialize(content:, name: nil, role: :developer)
  23. # Some parameter documentations has been truncated, see
  24. # {OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam} for more details.
  25. #
  26. # Developer-provided instructions that the model should follow, regardless of
  27. # messages sent by the user. With o1 models and newer, `developer` messages
  28. # replace the previous `system` messages.
  29. #
  30. # @param content [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>] The contents of the developer message.
  31. #
  32. # @param name [String] An optional name for the participant. Provides the model information to differen
  33. #
  34. # @param role [Symbol, :developer] The role of the messages author, in this case `developer`.
  35. # The contents of the developer message.
  36. #
  37. # @see OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam#content
  38. 1 module Content
  39. 1 extend OpenAI::Internal::Type::Union
  40. # The contents of the developer message.
  41. 1 variant String
  42. # An array of content parts with a defined type. For developer messages, only type `text` is supported.
  43. 1 variant -> { OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam::Content::ChatCompletionContentPartTextArray }
  44. # @!method self.variants
  45. # @return [Array(String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>)]
  46. # @type [OpenAI::Internal::Type::Converter]
  47. ChatCompletionContentPartTextArray =
  48. 1 OpenAI::Internal::Type::ArrayOf[-> { OpenAI::Chat::ChatCompletionContentPartText }]
  49. end
  50. end
  51. end
  52. 1 ChatCompletionDeveloperMessageParam = Chat::ChatCompletionDeveloperMessageParam
  53. end
  54. end

openai-ruby/lib/openai/models/chat/chat_completion_function_call_option.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionFunctionCallOption < OpenAI::Internal::Type::BaseModel
  6. # @!attribute name
  7. # The name of the function to call.
  8. #
  9. # @return [String]
  10. 1 required :name, String
  11. # @!method initialize(name:)
  12. # Specifying a particular function via `{"name": "my_function"}` forces the model
  13. # to call that function.
  14. #
  15. # @param name [String] The name of the function to call.
  16. end
  17. end
  18. 1 ChatCompletionFunctionCallOption = Chat::ChatCompletionFunctionCallOption
  19. end
  20. end

openai-ruby/lib/openai/models/chat/chat_completion_function_message_param.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # @deprecated
  6. 1 class ChatCompletionFunctionMessageParam < OpenAI::Internal::Type::BaseModel
  7. # @!attribute content
  8. # The contents of the function message.
  9. #
  10. # @return [String, nil]
  11. 1 required :content, String, nil?: true
  12. # @!attribute name
  13. # The name of the function to call.
  14. #
  15. # @return [String]
  16. 1 required :name, String
  17. # @!attribute role
  18. # The role of the messages author, in this case `function`.
  19. #
  20. # @return [Symbol, :function]
  21. 1 required :role, const: :function
  22. # @!method initialize(content:, name:, role: :function)
  23. # @param content [String, nil] The contents of the function message.
  24. #
  25. # @param name [String] The name of the function to call.
  26. #
  27. # @param role [Symbol, :function] The role of the messages author, in this case `function`.
  28. end
  29. end
  30. 1 ChatCompletionFunctionMessageParam = Chat::ChatCompletionFunctionMessageParam
  31. end
  32. end

openai-ruby/lib/openai/models/chat/chat_completion_message.rb

92.31% lines covered

100.0% branches covered

26 relevant lines. 24 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionMessage < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content
  7. # The contents of the message.
  8. #
  9. # @return [String, nil]
  10. 1 required :content, String, nil?: true
  11. # @!attribute parsed
  12. # The parsed contents of the message, if JSON schema is specified.
  13. #
  14. # @return [Object, nil]
  15. 1 optional :parsed, OpenAI::StructuredOutput::ParsedJson
  16. # @!attribute refusal
  17. # The refusal message generated by the model.
  18. #
  19. # @return [String, nil]
  20. 1 required :refusal, String, nil?: true
  21. # @!attribute role
  22. # The role of the author of this message.
  23. #
  24. # @return [Symbol, :assistant]
  25. 1 required :role, const: :assistant
  26. # @!attribute annotations
  27. # Annotations for the message, when applicable, as when using the
  28. # [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
  29. #
  30. # @return [Array<OpenAI::Models::Chat::ChatCompletionMessage::Annotation>, nil]
  31. 1 optional :annotations,
  32. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionMessage::Annotation] }
  33. # @!attribute audio
  34. # If the audio output modality is requested, this object contains data about the
  35. # audio response from the model.
  36. # [Learn more](https://platform.openai.com/docs/guides/audio).
  37. #
  38. # @return [OpenAI::Models::Chat::ChatCompletionAudio, nil]
  39. 1 optional :audio, -> { OpenAI::Chat::ChatCompletionAudio }, nil?: true
  40. # @!attribute function_call
  41. # @deprecated
  42. #
  43. # Deprecated and replaced by `tool_calls`. The name and arguments of a function
  44. # that should be called, as generated by the model.
  45. #
  46. # @return [OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall, nil]
  47. 1 optional :function_call, -> { OpenAI::Chat::ChatCompletionMessage::FunctionCall }
  48. # @!attribute tool_calls
  49. # The tool calls generated by the model, such as function calls.
  50. #
  51. # @return [Array<OpenAI::Models::Chat::ChatCompletionMessageToolCall>, nil]
  52. 1 optional :tool_calls,
  53. -> {
  54. OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionMessageToolCall]
  55. }
  56. # @!method initialize(content:, refusal:, annotations: nil, audio: nil, function_call: nil, tool_calls: nil, role: :assistant)
  57. # Some parameter documentations has been truncated, see
  58. # {OpenAI::Models::Chat::ChatCompletionMessage} for more details.
  59. #
  60. # A chat completion message generated by the model.
  61. #
  62. # @param content [String, nil] The contents of the message.
  63. #
  64. # @param refusal [String, nil] The refusal message generated by the model.
  65. #
  66. # @param annotations [Array<OpenAI::Models::Chat::ChatCompletionMessage::Annotation>] Annotations for the message, when applicable, as when using the
  67. #
  68. # @param audio [OpenAI::Models::Chat::ChatCompletionAudio, nil] If the audio output modality is requested, this object contains data
  69. #
  70. # @param function_call [OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall] Deprecated and replaced by `tool_calls`. The name and arguments of a function th
  71. #
  72. # @param tool_calls [Array<OpenAI::Models::Chat::ChatCompletionMessageToolCall>] The tool calls generated by the model, such as function calls.
  73. #
  74. # @param role [Symbol, :assistant] The role of the author of this message.
  75. 1 class Annotation < OpenAI::Internal::Type::BaseModel
  76. # @!attribute type
  77. # The type of the URL citation. Always `url_citation`.
  78. #
  79. # @return [Symbol, :url_citation]
  80. 1 required :type, const: :url_citation
  81. # @!attribute url_citation
  82. # A URL citation when using web search.
  83. #
  84. # @return [OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation]
  85. 1 required :url_citation, -> { OpenAI::Chat::ChatCompletionMessage::Annotation::URLCitation }
  86. # @!method initialize(url_citation:, type: :url_citation)
  87. # A URL citation when using web search.
  88. #
  89. # @param url_citation [OpenAI::Models::Chat::ChatCompletionMessage::Annotation::URLCitation] A URL citation when using web search.
  90. #
  91. # @param type [Symbol, :url_citation] The type of the URL citation. Always `url_citation`.
  92. # @see OpenAI::Models::Chat::ChatCompletionMessage::Annotation#url_citation
  93. 1 class URLCitation < OpenAI::Internal::Type::BaseModel
  94. # @!attribute end_index
  95. # The index of the last character of the URL citation in the message.
  96. #
  97. # @return [Integer]
  98. 1 required :end_index, Integer
  99. # @!attribute start_index
  100. # The index of the first character of the URL citation in the message.
  101. #
  102. # @return [Integer]
  103. 1 required :start_index, Integer
  104. # @!attribute title
  105. # The title of the web resource.
  106. #
  107. # @return [String]
  108. 1 required :title, String
  109. # @!attribute url
  110. # The URL of the web resource.
  111. #
  112. # @return [String]
  113. 1 required :url, String
  114. # @!method initialize(end_index:, start_index:, title:, url:)
  115. # A URL citation when using web search.
  116. #
  117. # @param end_index [Integer] The index of the last character of the URL citation in the message.
  118. #
  119. # @param start_index [Integer] The index of the first character of the URL citation in the message.
  120. #
  121. # @param title [String] The title of the web resource.
  122. #
  123. # @param url [String] The URL of the web resource.
  124. end
  125. end
  126. # @deprecated
  127. #
  128. # @see OpenAI::Models::Chat::ChatCompletionMessage#function_call
  129. 1 class FunctionCall < OpenAI::Internal::Type::BaseModel
  130. # @!attribute arguments
  131. # The arguments to call the function with, as generated by the model in JSON
  132. # format. Note that the model does not always generate valid JSON, and may
  133. # hallucinate parameters not defined by your function schema. Validate the
  134. # arguments in your code before calling your function.
  135. #
  136. # @return [String]
  137. 1 required :arguments, String
  138. # @!attribute name
  139. # The name of the function to call.
  140. #
  141. # @return [String]
  142. 1 required :name, String
  143. # @!method initialize(arguments:, name:)
  144. # Some parameter documentations has been truncated, see
  145. # {OpenAI::Models::Chat::ChatCompletionMessage::FunctionCall} for more details.
  146. #
  147. # Deprecated and replaced by `tool_calls`. The name and arguments of a function
  148. # that should be called, as generated by the model.
  149. #
  150. # @param arguments [String] The arguments to call the function with, as generated by the model in JSON forma
  151. #
  152. # @param name [String] The name of the function to call.
  153. end
  154. end
  155. end
  156. 1 ChatCompletionMessage = Chat::ChatCompletionMessage
  157. end
  158. end

openai-ruby/lib/openai/models/chat/chat_completion_message_param.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # Developer-provided instructions that the model should follow, regardless of
  6. # messages sent by the user. With o1 models and newer, `developer` messages
  7. # replace the previous `system` messages.
  8. 1 module ChatCompletionMessageParam
  9. 1 extend OpenAI::Internal::Type::Union
  10. 1 discriminator :role
  11. # Developer-provided instructions that the model should follow, regardless of
  12. # messages sent by the user. With o1 models and newer, `developer` messages
  13. # replace the previous `system` messages.
  14. 1 variant :developer, -> { OpenAI::Chat::ChatCompletionDeveloperMessageParam }
  15. # Developer-provided instructions that the model should follow, regardless of
  16. # messages sent by the user. With o1 models and newer, use `developer` messages
  17. # for this purpose instead.
  18. 1 variant :system, -> { OpenAI::Chat::ChatCompletionSystemMessageParam }
  19. # Messages sent by an end user, containing prompts or additional context
  20. # information.
  21. 1 variant :user, -> { OpenAI::Chat::ChatCompletionUserMessageParam }
  22. # Messages sent by the model in response to user messages.
  23. 1 variant :assistant, -> { OpenAI::Chat::ChatCompletionAssistantMessageParam }
  24. 1 variant :tool, -> { OpenAI::Chat::ChatCompletionToolMessageParam }
  25. 1 variant :function, -> { OpenAI::Chat::ChatCompletionFunctionMessageParam }
  26. # @!method self.variants
  27. # @return [Array(OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam)]
  28. end
  29. end
  30. 1 ChatCompletionMessageParam = Chat::ChatCompletionMessageParam
  31. end
  32. end

openai-ruby/lib/openai/models/chat/chat_completion_message_tool_call.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionMessageToolCall < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The ID of the tool call.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute function
  12. # The function that the model called.
  13. #
  14. # @return [OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function]
  15. 1 required :function, -> { OpenAI::Chat::ChatCompletionMessageToolCall::Function }
  16. # @!attribute type
  17. # The type of the tool. Currently, only `function` is supported.
  18. #
  19. # @return [Symbol, :function]
  20. 1 required :type, const: :function
  21. # @!method initialize(id:, function:, type: :function)
  22. # @param id [String] The ID of the tool call.
  23. #
  24. # @param function [OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function] The function that the model called.
  25. #
  26. # @param type [Symbol, :function] The type of the tool. Currently, only `function` is supported.
  27. # @see OpenAI::Models::Chat::ChatCompletionMessageToolCall#function
  28. 1 class Function < OpenAI::Internal::Type::BaseModel
  29. # @!attribute arguments
  30. # The arguments to call the function with, as generated by the model in JSON
  31. # format. Note that the model does not always generate valid JSON, and may
  32. # hallucinate parameters not defined by your function schema. Validate the
  33. # arguments in your code before calling your function.
  34. #
  35. # @return [String]
  36. 1 required :arguments, String
  37. # @!attribute parsed
  38. # The parsed contents of the arguments.
  39. #
  40. # @return [Object, nil]
  41. 1 required :parsed, OpenAI::StructuredOutput::ParsedJson
  42. # @!attribute name
  43. # The name of the function to call.
  44. #
  45. # @return [String]
  46. 1 required :name, String
  47. # @!method initialize(arguments:, name:)
  48. # Some parameter documentations has been truncated, see
  49. # {OpenAI::Models::Chat::ChatCompletionMessageToolCall::Function} for more
  50. # details.
  51. #
  52. # The function that the model called.
  53. #
  54. # @param arguments [String] The arguments to call the function with, as generated by the model in JSON forma
  55. #
  56. # @param name [String] The name of the function to call.
  57. end
  58. end
  59. end
  60. 1 ChatCompletionMessageToolCall = Chat::ChatCompletionMessageToolCall
  61. end
  62. end

openai-ruby/lib/openai/models/chat/chat_completion_modality.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 module ChatCompletionModality
  6. 1 extend OpenAI::Internal::Type::Enum
  7. 1 TEXT = :text
  8. 1 AUDIO = :audio
  9. # @!method self.values
  10. # @return [Array<Symbol>]
  11. end
  12. end
  13. 1 ChatCompletionModality = Chat::ChatCompletionModality
  14. end
  15. end

openai-ruby/lib/openai/models/chat/chat_completion_named_tool_choice.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionNamedToolChoice < OpenAI::Internal::Type::BaseModel
  6. # @!attribute function
  7. #
  8. # @return [OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function]
  9. 1 required :function, -> { OpenAI::Chat::ChatCompletionNamedToolChoice::Function }
  10. # @!attribute type
  11. # The type of the tool. Currently, only `function` is supported.
  12. #
  13. # @return [Symbol, :function]
  14. 1 required :type, const: :function
  15. # @!method initialize(function:, type: :function)
  16. # Specifies a tool the model should use. Use to force the model to call a specific
  17. # function.
  18. #
  19. # @param function [OpenAI::Models::Chat::ChatCompletionNamedToolChoice::Function]
  20. #
  21. # @param type [Symbol, :function] The type of the tool. Currently, only `function` is supported.
  22. # @see OpenAI::Models::Chat::ChatCompletionNamedToolChoice#function
  23. 1 class Function < OpenAI::Internal::Type::BaseModel
  24. # @!attribute name
  25. # The name of the function to call.
  26. #
  27. # @return [String]
  28. 1 required :name, String
  29. # @!method initialize(name:)
  30. # @param name [String] The name of the function to call.
  31. end
  32. end
  33. end
  34. 1 ChatCompletionNamedToolChoice = Chat::ChatCompletionNamedToolChoice
  35. end
  36. end

openai-ruby/lib/openai/models/chat/chat_completion_prediction_content.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionPredictionContent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content
  7. # The content that should be matched when generating a model response. If
  8. # generated tokens would match this content, the entire model response can be
  9. # returned much more quickly.
  10. #
  11. # @return [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>]
  12. 1 required :content, union: -> { OpenAI::Chat::ChatCompletionPredictionContent::Content }
  13. # @!attribute type
  14. # The type of the predicted content you want to provide. This type is currently
  15. # always `content`.
  16. #
  17. # @return [Symbol, :content]
  18. 1 required :type, const: :content
  19. # @!method initialize(content:, type: :content)
  20. # Some parameter documentations has been truncated, see
  21. # {OpenAI::Models::Chat::ChatCompletionPredictionContent} for more details.
  22. #
  23. # Static predicted output content, such as the content of a text file that is
  24. # being regenerated.
  25. #
  26. # @param content [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>] The content that should be matched when generating a model response.
  27. #
  28. # @param type [Symbol, :content] The type of the predicted content you want to provide. This type is
  29. # The content that should be matched when generating a model response. If
  30. # generated tokens would match this content, the entire model response can be
  31. # returned much more quickly.
  32. #
  33. # @see OpenAI::Models::Chat::ChatCompletionPredictionContent#content
  34. 1 module Content
  35. 1 extend OpenAI::Internal::Type::Union
  36. # The content used for a Predicted Output. This is often the
  37. # text of a file you are regenerating with minor changes.
  38. 1 variant String
  39. # An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text inputs.
  40. 1 variant -> { OpenAI::Models::Chat::ChatCompletionPredictionContent::Content::ChatCompletionContentPartTextArray }
  41. # @!method self.variants
  42. # @return [Array(String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>)]
  43. # @type [OpenAI::Internal::Type::Converter]
  44. ChatCompletionContentPartTextArray =
  45. 1 OpenAI::Internal::Type::ArrayOf[-> { OpenAI::Chat::ChatCompletionContentPartText }]
  46. end
  47. end
  48. end
  49. 1 ChatCompletionPredictionContent = Chat::ChatCompletionPredictionContent
  50. end
  51. end

openai-ruby/lib/openai/models/chat/chat_completion_reasoning_effort.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 ChatCompletionReasoningEffort = OpenAI::Models::ReasoningEffort
  6. end
  7. 1 ChatCompletionReasoningEffort = Chat::ChatCompletionReasoningEffort
  8. end
  9. end

openai-ruby/lib/openai/models/chat/chat_completion_role.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # The role of the author of a message
  6. 1 module ChatCompletionRole
  7. 1 extend OpenAI::Internal::Type::Enum
  8. 1 DEVELOPER = :developer
  9. 1 SYSTEM = :system
  10. 1 USER = :user
  11. 1 ASSISTANT = :assistant
  12. 1 TOOL = :tool
  13. 1 FUNCTION = :function
  14. # @!method self.values
  15. # @return [Array<Symbol>]
  16. end
  17. end
  18. 1 ChatCompletionRole = Chat::ChatCompletionRole
  19. end
  20. end

openai-ruby/lib/openai/models/chat/chat_completion_store_message.rb

91.67% lines covered

100.0% branches covered

12 relevant lines. 11 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionStoreMessage < OpenAI::Models::Chat::ChatCompletionMessage
  6. # @!attribute id
  7. # The identifier of the chat message.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute content_parts
  12. # If a content parts array was provided, this is an array of `text` and
  13. # `image_url` parts. Otherwise, null.
  14. #
  15. # @return [Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage>, nil]
  16. 1 optional :content_parts,
  17. -> {
  18. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Chat::ChatCompletionStoreMessage::ContentPart]
  19. },
  20. nil?: true
  21. # @!method initialize(id:, content_parts: nil)
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Chat::ChatCompletionStoreMessage} for more details.
  24. #
  25. # A chat completion message generated by the model.
  26. #
  27. # @param id [String] The identifier of the chat message.
  28. #
  29. # @param content_parts [Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage>, nil] If a content parts array was provided, this is an array of `text` and `image_url
  30. # Learn about
  31. # [text inputs](https://platform.openai.com/docs/guides/text-generation).
  32. 1 module ContentPart
  33. 1 extend OpenAI::Internal::Type::Union
  34. # Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation).
  35. 1 variant -> { OpenAI::Chat::ChatCompletionContentPartText }
  36. # Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
  37. 1 variant -> { OpenAI::Chat::ChatCompletionContentPartImage }
  38. # @!method self.variants
  39. # @return [Array(OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage)]
  40. end
  41. end
  42. end
  43. 1 ChatCompletionStoreMessage = Chat::ChatCompletionStoreMessage
  44. end
  45. end

openai-ruby/lib/openai/models/chat/chat_completion_stream_options.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionStreamOptions < OpenAI::Internal::Type::BaseModel
  6. # @!attribute include_usage
  7. # If set, an additional chunk will be streamed before the `data: [DONE]` message.
  8. # The `usage` field on this chunk shows the token usage statistics for the entire
  9. # request, and the `choices` field will always be an empty array.
  10. #
  11. # All other chunks will also include a `usage` field, but with a null value.
  12. # **NOTE:** If the stream is interrupted, you may not receive the final usage
  13. # chunk which contains the total token usage for the request.
  14. #
  15. # @return [Boolean, nil]
  16. 1 optional :include_usage, OpenAI::Internal::Type::Boolean
  17. # @!method initialize(include_usage: nil)
  18. # Some parameter documentations has been truncated, see
  19. # {OpenAI::Models::Chat::ChatCompletionStreamOptions} for more details.
  20. #
  21. # Options for streaming response. Only set this when you set `stream: true`.
  22. #
  23. # @param include_usage [Boolean] If set, an additional chunk will be streamed before the `data: [DONE]`
  24. end
  25. end
  26. 1 ChatCompletionStreamOptions = Chat::ChatCompletionStreamOptions
  27. end
  28. end

openai-ruby/lib/openai/models/chat/chat_completion_system_message_param.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionSystemMessageParam < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content
  7. # The contents of the system message.
  8. #
  9. # @return [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>]
  10. 1 required :content, union: -> { OpenAI::Chat::ChatCompletionSystemMessageParam::Content }
  11. # @!attribute role
  12. # The role of the messages author, in this case `system`.
  13. #
  14. # @return [Symbol, :system]
  15. 1 required :role, const: :system
  16. # @!attribute name
  17. # An optional name for the participant. Provides the model information to
  18. # differentiate between participants of the same role.
  19. #
  20. # @return [String, nil]
  21. 1 optional :name, String
  22. # @!method initialize(content:, name: nil, role: :system)
  23. # Some parameter documentations has been truncated, see
  24. # {OpenAI::Models::Chat::ChatCompletionSystemMessageParam} for more details.
  25. #
  26. # Developer-provided instructions that the model should follow, regardless of
  27. # messages sent by the user. With o1 models and newer, use `developer` messages
  28. # for this purpose instead.
  29. #
  30. # @param content [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>] The contents of the system message.
  31. #
  32. # @param name [String] An optional name for the participant. Provides the model information to differen
  33. #
  34. # @param role [Symbol, :system] The role of the messages author, in this case `system`.
  35. # The contents of the system message.
  36. #
  37. # @see OpenAI::Models::Chat::ChatCompletionSystemMessageParam#content
  38. 1 module Content
  39. 1 extend OpenAI::Internal::Type::Union
  40. # The contents of the system message.
  41. 1 variant String
  42. # An array of content parts with a defined type. For system messages, only type `text` is supported.
  43. 1 variant -> { OpenAI::Models::Chat::ChatCompletionSystemMessageParam::Content::ChatCompletionContentPartTextArray }
  44. # @!method self.variants
  45. # @return [Array(String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>)]
  46. # @type [OpenAI::Internal::Type::Converter]
  47. ChatCompletionContentPartTextArray =
  48. 1 OpenAI::Internal::Type::ArrayOf[-> { OpenAI::Chat::ChatCompletionContentPartText }]
  49. end
  50. end
  51. end
  52. 1 ChatCompletionSystemMessageParam = Chat::ChatCompletionSystemMessageParam
  53. end
  54. end

openai-ruby/lib/openai/models/chat/chat_completion_token_logprob.rb

92.86% lines covered

100.0% branches covered

14 relevant lines. 13 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionTokenLogprob < OpenAI::Internal::Type::BaseModel
  6. # @!attribute token
  7. # The token.
  8. #
  9. # @return [String]
  10. 1 required :token, String
  11. # @!attribute bytes
  12. # A list of integers representing the UTF-8 bytes representation of the token.
  13. # Useful in instances where characters are represented by multiple tokens and
  14. # their byte representations must be combined to generate the correct text
  15. # representation. Can be `null` if there is no bytes representation for the token.
  16. #
  17. # @return [Array<Integer>, nil]
  18. 1 required :bytes, OpenAI::Internal::Type::ArrayOf[Integer], nil?: true
  19. # @!attribute logprob
  20. # The log probability of this token, if it is within the top 20 most likely
  21. # tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
  22. # unlikely.
  23. #
  24. # @return [Float]
  25. 1 required :logprob, Float
  26. # @!attribute top_logprobs
  27. # List of the most likely tokens and their log probability, at this token
  28. # position. In rare cases, there may be fewer than the number of requested
  29. # `top_logprobs` returned.
  30. #
  31. # @return [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob>]
  32. 1 required :top_logprobs,
  33. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionTokenLogprob::TopLogprob] }
  34. # @!method initialize(token:, bytes:, logprob:, top_logprobs:)
  35. # Some parameter documentations has been truncated, see
  36. # {OpenAI::Models::Chat::ChatCompletionTokenLogprob} for more details.
  37. #
  38. # @param token [String] The token.
  39. #
  40. # @param bytes [Array<Integer>, nil] A list of integers representing the UTF-8 bytes representation of the token. Use
  41. #
  42. # @param logprob [Float] The log probability of this token, if it is within the top 20 most likely tokens
  43. #
  44. # @param top_logprobs [Array<OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob>] List of the most likely tokens and their log probability, at this token position
  45. 1 class TopLogprob < OpenAI::Internal::Type::BaseModel
  46. # @!attribute token
  47. # The token.
  48. #
  49. # @return [String]
  50. 1 required :token, String
  51. # @!attribute bytes
  52. # A list of integers representing the UTF-8 bytes representation of the token.
  53. # Useful in instances where characters are represented by multiple tokens and
  54. # their byte representations must be combined to generate the correct text
  55. # representation. Can be `null` if there is no bytes representation for the token.
  56. #
  57. # @return [Array<Integer>, nil]
  58. 1 required :bytes, OpenAI::Internal::Type::ArrayOf[Integer], nil?: true
  59. # @!attribute logprob
  60. # The log probability of this token, if it is within the top 20 most likely
  61. # tokens. Otherwise, the value `-9999.0` is used to signify that the token is very
  62. # unlikely.
  63. #
  64. # @return [Float]
  65. 1 required :logprob, Float
  66. # @!method initialize(token:, bytes:, logprob:)
  67. # Some parameter documentations has been truncated, see
  68. # {OpenAI::Models::Chat::ChatCompletionTokenLogprob::TopLogprob} for more details.
  69. #
  70. # @param token [String] The token.
  71. #
  72. # @param bytes [Array<Integer>, nil] A list of integers representing the UTF-8 bytes representation of the token. Use
  73. #
  74. # @param logprob [Float] The log probability of this token, if it is within the top 20 most likely tokens
  75. end
  76. end
  77. end
  78. 1 ChatCompletionTokenLogprob = Chat::ChatCompletionTokenLogprob
  79. end
  80. end

openai-ruby/lib/openai/models/chat/chat_completion_tool.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionTool < OpenAI::Internal::Type::BaseModel
  6. # @!attribute function
  7. #
  8. # @return [OpenAI::Models::FunctionDefinition]
  9. 1 required :function, -> { OpenAI::FunctionDefinition }
  10. # @!attribute type
  11. # The type of the tool. Currently, only `function` is supported.
  12. #
  13. # @return [Symbol, :function]
  14. 1 required :type, const: :function
  15. # @!method initialize(function:, type: :function)
  16. # @param function [OpenAI::Models::FunctionDefinition]
  17. #
  18. # @param type [Symbol, :function] The type of the tool. Currently, only `function` is supported.
  19. end
  20. end
  21. 1 ChatCompletionTool = Chat::ChatCompletionTool
  22. end
  23. end

openai-ruby/lib/openai/models/chat/chat_completion_tool_choice_option.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # Controls which (if any) tool is called by the model. `none` means the model will
  6. # not call any tool and instead generates a message. `auto` means the model can
  7. # pick between generating a message or calling one or more tools. `required` means
  8. # the model must call one or more tools. Specifying a particular tool via
  9. # `{"type": "function", "function": {"name": "my_function"}}` forces the model to
  10. # call that tool.
  11. #
  12. # `none` is the default when no tools are present. `auto` is the default if tools
  13. # are present.
  14. 1 module ChatCompletionToolChoiceOption
  15. 1 extend OpenAI::Internal::Type::Union
  16. # `none` means the model will not call any tool and instead generates a message. `auto` means the model can pick between generating a message or calling one or more tools. `required` means the model must call one or more tools.
  17. 1 variant enum: -> { OpenAI::Chat::ChatCompletionToolChoiceOption::Auto }
  18. # Specifies a tool the model should use. Use to force the model to call a specific function.
  19. 1 variant -> { OpenAI::Chat::ChatCompletionNamedToolChoice }
  20. # `none` means the model will not call any tool and instead generates a message.
  21. # `auto` means the model can pick between generating a message or calling one or
  22. # more tools. `required` means the model must call one or more tools.
  23. 1 module Auto
  24. 1 extend OpenAI::Internal::Type::Enum
  25. 1 NONE = :none
  26. 1 AUTO = :auto
  27. 1 REQUIRED = :required
  28. # @!method self.values
  29. # @return [Array<Symbol>]
  30. end
  31. # @!method self.variants
  32. # @return [Array(Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionNamedToolChoice)]
  33. end
  34. end
  35. 1 ChatCompletionToolChoiceOption = Chat::ChatCompletionToolChoiceOption
  36. end
  37. end

openai-ruby/lib/openai/models/chat/chat_completion_tool_message_param.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionToolMessageParam < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content
  7. # The contents of the tool message.
  8. #
  9. # @return [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>]
  10. 1 required :content, union: -> { OpenAI::Chat::ChatCompletionToolMessageParam::Content }
  11. # @!attribute role
  12. # The role of the messages author, in this case `tool`.
  13. #
  14. # @return [Symbol, :tool]
  15. 1 required :role, const: :tool
  16. # @!attribute tool_call_id
  17. # Tool call that this message is responding to.
  18. #
  19. # @return [String]
  20. 1 required :tool_call_id, String
  21. # @!method initialize(content:, tool_call_id:, role: :tool)
  22. # @param content [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>] The contents of the tool message.
  23. #
  24. # @param tool_call_id [String] Tool call that this message is responding to.
  25. #
  26. # @param role [Symbol, :tool] The role of the messages author, in this case `tool`.
  27. # The contents of the tool message.
  28. #
  29. # @see OpenAI::Models::Chat::ChatCompletionToolMessageParam#content
  30. 1 module Content
  31. 1 extend OpenAI::Internal::Type::Union
  32. # The contents of the tool message.
  33. 1 variant String
  34. # An array of content parts with a defined type. For tool messages, only type `text` is supported.
  35. 1 variant -> { OpenAI::Models::Chat::ChatCompletionToolMessageParam::Content::ChatCompletionContentPartTextArray }
  36. # @!method self.variants
  37. # @return [Array(String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText>)]
  38. # @type [OpenAI::Internal::Type::Converter]
  39. ChatCompletionContentPartTextArray =
  40. 1 OpenAI::Internal::Type::ArrayOf[-> { OpenAI::Chat::ChatCompletionContentPartText }]
  41. end
  42. end
  43. end
  44. 1 ChatCompletionToolMessageParam = Chat::ChatCompletionToolMessageParam
  45. end
  46. end

openai-ruby/lib/openai/models/chat/chat_completion_user_message_param.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 class ChatCompletionUserMessageParam < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content
  7. # The contents of the user message.
  8. #
  9. # @return [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File>]
  10. 1 required :content, union: -> { OpenAI::Chat::ChatCompletionUserMessageParam::Content }
  11. # @!attribute role
  12. # The role of the messages author, in this case `user`.
  13. #
  14. # @return [Symbol, :user]
  15. 1 required :role, const: :user
  16. # @!attribute name
  17. # An optional name for the participant. Provides the model information to
  18. # differentiate between participants of the same role.
  19. #
  20. # @return [String, nil]
  21. 1 optional :name, String
  22. # @!method initialize(content:, name: nil, role: :user)
  23. # Some parameter documentations has been truncated, see
  24. # {OpenAI::Models::Chat::ChatCompletionUserMessageParam} for more details.
  25. #
  26. # Messages sent by an end user, containing prompts or additional context
  27. # information.
  28. #
  29. # @param content [String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File>] The contents of the user message.
  30. #
  31. # @param name [String] An optional name for the participant. Provides the model information to differen
  32. #
  33. # @param role [Symbol, :user] The role of the messages author, in this case `user`.
  34. # The contents of the user message.
  35. #
  36. # @see OpenAI::Models::Chat::ChatCompletionUserMessageParam#content
  37. 1 module Content
  38. 1 extend OpenAI::Internal::Type::Union
  39. # The text contents of the message.
  40. 1 variant String
  41. # An array of content parts with a defined type. Supported options differ based on the [model](https://platform.openai.com/docs/models) being used to generate the response. Can contain text, image, or audio inputs.
  42. 1 variant -> { OpenAI::Models::Chat::ChatCompletionUserMessageParam::Content::ChatCompletionContentPartArray }
  43. # @!method self.variants
  44. # @return [Array(String, Array<OpenAI::Models::Chat::ChatCompletionContentPartText, OpenAI::Models::Chat::ChatCompletionContentPartImage, OpenAI::Models::Chat::ChatCompletionContentPartInputAudio, OpenAI::Models::Chat::ChatCompletionContentPart::File>)]
  45. # @type [OpenAI::Internal::Type::Converter]
  46. ChatCompletionContentPartArray =
  47. 1 OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Chat::ChatCompletionContentPart }]
  48. end
  49. end
  50. end
  51. 1 ChatCompletionUserMessageParam = Chat::ChatCompletionUserMessageParam
  52. end
  53. end

openai-ruby/lib/openai/models/chat/completion_create_params.rb

92.93% lines covered

100.0% branches covered

99 relevant lines. 92 lines covered and 7 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # @see OpenAI::Resources::Chat::Completions#create
  6. #
  7. # @see OpenAI::Resources::Chat::Completions#stream_raw
  8. 1 class CompletionCreateParams < OpenAI::Internal::Type::BaseModel
  9. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  10. 1 include OpenAI::Internal::Type::RequestParameters
  11. # @!attribute messages
  12. # A list of messages comprising the conversation so far. Depending on the
  13. # [model](https://platform.openai.com/docs/models) you use, different message
  14. # types (modalities) are supported, like
  15. # [text](https://platform.openai.com/docs/guides/text-generation),
  16. # [images](https://platform.openai.com/docs/guides/vision), and
  17. # [audio](https://platform.openai.com/docs/guides/audio).
  18. #
  19. # @return [Array<OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam>]
  20. 1 required :messages,
  21. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Chat::ChatCompletionMessageParam] }
  22. # @!attribute model
  23. # Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
  24. # wide range of models with different capabilities, performance characteristics,
  25. # and price points. Refer to the
  26. # [model guide](https://platform.openai.com/docs/models) to browse and compare
  27. # available models.
  28. #
  29. # @return [String, Symbol, OpenAI::Models::ChatModel]
  30. 1 required :model, union: -> { OpenAI::Chat::CompletionCreateParams::Model }
  31. # @!attribute audio
  32. # Parameters for audio output. Required when audio output is requested with
  33. # `modalities: ["audio"]`.
  34. # [Learn more](https://platform.openai.com/docs/guides/audio).
  35. #
  36. # @return [OpenAI::Models::Chat::ChatCompletionAudioParam, nil]
  37. 1 optional :audio, -> { OpenAI::Chat::ChatCompletionAudioParam }, nil?: true
  38. # @!attribute frequency_penalty
  39. # Number between -2.0 and 2.0. Positive values penalize new tokens based on their
  40. # existing frequency in the text so far, decreasing the model's likelihood to
  41. # repeat the same line verbatim.
  42. #
  43. # @return [Float, nil]
  44. 1 optional :frequency_penalty, Float, nil?: true
  45. # @!attribute function_call
  46. # @deprecated
  47. #
  48. # Deprecated in favor of `tool_choice`.
  49. #
  50. # Controls which (if any) function is called by the model.
  51. #
  52. # `none` means the model will not call a function and instead generates a message.
  53. #
  54. # `auto` means the model can pick between generating a message or calling a
  55. # function.
  56. #
  57. # Specifying a particular function via `{"name": "my_function"}` forces the model
  58. # to call that function.
  59. #
  60. # `none` is the default when no functions are present. `auto` is the default if
  61. # functions are present.
  62. #
  63. # @return [Symbol, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode, OpenAI::Models::Chat::ChatCompletionFunctionCallOption, nil]
  64. 1 optional :function_call, union: -> { OpenAI::Chat::CompletionCreateParams::FunctionCall }
  65. # @!attribute functions
  66. # @deprecated
  67. #
  68. # Deprecated in favor of `tools`.
  69. #
  70. # A list of functions the model may generate JSON inputs for.
  71. #
  72. # @return [Array<OpenAI::Models::Chat::CompletionCreateParams::Function>, nil]
  73. 1 optional :functions,
  74. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::CompletionCreateParams::Function] }
  75. # @!attribute logit_bias
  76. # Modify the likelihood of specified tokens appearing in the completion.
  77. #
  78. # Accepts a JSON object that maps tokens (specified by their token ID in the
  79. # tokenizer) to an associated bias value from -100 to 100. Mathematically, the
  80. # bias is added to the logits generated by the model prior to sampling. The exact
  81. # effect will vary per model, but values between -1 and 1 should decrease or
  82. # increase likelihood of selection; values like -100 or 100 should result in a ban
  83. # or exclusive selection of the relevant token.
  84. #
  85. # @return [Hash{Symbol=>Integer}, nil]
  86. 1 optional :logit_bias, OpenAI::Internal::Type::HashOf[Integer], nil?: true
  87. # @!attribute logprobs
  88. # Whether to return log probabilities of the output tokens or not. If true,
  89. # returns the log probabilities of each output token returned in the `content` of
  90. # `message`.
  91. #
  92. # @return [Boolean, nil]
  93. 1 optional :logprobs, OpenAI::Internal::Type::Boolean, nil?: true
  94. # @!attribute max_completion_tokens
  95. # An upper bound for the number of tokens that can be generated for a completion,
  96. # including visible output tokens and
  97. # [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
  98. #
  99. # @return [Integer, nil]
  100. 1 optional :max_completion_tokens, Integer, nil?: true
  101. # @!attribute max_tokens
  102. # @deprecated
  103. #
  104. # The maximum number of [tokens](/tokenizer) that can be generated in the chat
  105. # completion. This value can be used to control
  106. # [costs](https://openai.com/api/pricing/) for text generated via API.
  107. #
  108. # This value is now deprecated in favor of `max_completion_tokens`, and is not
  109. # compatible with
  110. # [o-series models](https://platform.openai.com/docs/guides/reasoning).
  111. #
  112. # @return [Integer, nil]
  113. 1 optional :max_tokens, Integer, nil?: true
  114. # @!attribute metadata
  115. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  116. # for storing additional information about the object in a structured format, and
  117. # querying for objects via API or the dashboard.
  118. #
  119. # Keys are strings with a maximum length of 64 characters. Values are strings with
  120. # a maximum length of 512 characters.
  121. #
  122. # @return [Hash{Symbol=>String}, nil]
  123. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  124. # @!attribute modalities
  125. # Output types that you would like the model to generate. Most models are capable
  126. # of generating text, which is the default:
  127. #
  128. # `["text"]`
  129. #
  130. # The `gpt-4o-audio-preview` model can also be used to
  131. # [generate audio](https://platform.openai.com/docs/guides/audio). To request that
  132. # this model generate both text and audio responses, you can use:
  133. #
  134. # `["text", "audio"]`
  135. #
  136. # @return [Array<Symbol, OpenAI::Models::Chat::CompletionCreateParams::Modality>, nil]
  137. 1 optional :modalities,
  138. -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Chat::CompletionCreateParams::Modality] },
  139. nil?: true
  140. # @!attribute n
  141. # How many chat completion choices to generate for each input message. Note that
  142. # you will be charged based on the number of generated tokens across all of the
  143. # choices. Keep `n` as `1` to minimize costs.
  144. #
  145. # @return [Integer, nil]
  146. 1 optional :n, Integer, nil?: true
  147. # @!attribute parallel_tool_calls
  148. # Whether to enable
  149. # [parallel function calling](https://platform.openai.com/docs/guides/function-calling#configuring-parallel-function-calling)
  150. # during tool use.
  151. #
  152. # @return [Boolean, nil]
  153. 1 optional :parallel_tool_calls, OpenAI::Internal::Type::Boolean
  154. # @!attribute prediction
  155. # Static predicted output content, such as the content of a text file that is
  156. # being regenerated.
  157. #
  158. # @return [OpenAI::Models::Chat::ChatCompletionPredictionContent, nil]
  159. 1 optional :prediction, -> { OpenAI::Chat::ChatCompletionPredictionContent }, nil?: true
  160. # @!attribute presence_penalty
  161. # Number between -2.0 and 2.0. Positive values penalize new tokens based on
  162. # whether they appear in the text so far, increasing the model's likelihood to
  163. # talk about new topics.
  164. #
  165. # @return [Float, nil]
  166. 1 optional :presence_penalty, Float, nil?: true
  167. # @!attribute prompt_cache_key
  168. # Used by OpenAI to cache responses for similar requests to optimize your cache
  169. # hit rates. Replaces the `user` field.
  170. # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
  171. #
  172. # @return [String, nil]
  173. 1 optional :prompt_cache_key, String
  174. # @!attribute reasoning_effort
  175. # **o-series models only**
  176. #
  177. # Constrains effort on reasoning for
  178. # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
  179. # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
  180. # result in faster responses and fewer tokens used on reasoning in a response.
  181. #
  182. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  183. 1 optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  184. # @!attribute response_format
  185. # An object specifying the format that the model must output.
  186. #
  187. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  188. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  189. # in the
  190. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  191. #
  192. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  193. # ensures the message the model generates is valid JSON. Using `json_schema` is
  194. # preferred for models that support it.
  195. #
  196. # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::StructuredOutput::JsonSchemaConverter, OpenAI::Models::ResponseFormatJSONObject, nil]
  197. 1 optional :response_format, union: -> { OpenAI::Chat::CompletionCreateParams::ResponseFormat }
  198. # @!attribute safety_identifier
  199. # A stable identifier used to help detect users of your application that may be
  200. # violating OpenAI's usage policies. The IDs should be a string that uniquely
  201. # identifies each user. We recommend hashing their username or email address, in
  202. # order to avoid sending us any identifying information.
  203. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
  204. #
  205. # @return [String, nil]
  206. 1 optional :safety_identifier, String
  207. # @!attribute seed
  208. # This feature is in Beta. If specified, our system will make a best effort to
  209. # sample deterministically, such that repeated requests with the same `seed` and
  210. # parameters should return the same result. Determinism is not guaranteed, and you
  211. # should refer to the `system_fingerprint` response parameter to monitor changes
  212. # in the backend.
  213. #
  214. # @return [Integer, nil]
  215. 1 optional :seed, Integer, nil?: true
  216. # @!attribute service_tier
  217. # Specifies the processing type used for serving the request.
  218. #
  219. # - If set to 'auto', then the request will be processed with the service tier
  220. # configured in the Project settings. Unless otherwise configured, the Project
  221. # will use 'default'.
  222. # - If set to 'default', then the request will be processed with the standard
  223. # pricing and performance for the selected model.
  224. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  225. # 'priority', then the request will be processed with the corresponding service
  226. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  227. # Priority processing.
  228. # - When not set, the default behavior is 'auto'.
  229. #
  230. # When the `service_tier` parameter is set, the response body will include the
  231. # `service_tier` value based on the processing mode actually used to serve the
  232. # request. This response value may be different from the value set in the
  233. # parameter.
  234. #
  235. # @return [Symbol, OpenAI::Models::Chat::CompletionCreateParams::ServiceTier, nil]
  236. 1 optional :service_tier, enum: -> { OpenAI::Chat::CompletionCreateParams::ServiceTier }, nil?: true
  237. # @!attribute stop
  238. # Not supported with latest reasoning models `o3` and `o4-mini`.
  239. #
  240. # Up to 4 sequences where the API will stop generating further tokens. The
  241. # returned text will not contain the stop sequence.
  242. #
  243. # @return [String, Array<String>, nil]
  244. 1 optional :stop, union: -> { OpenAI::Chat::CompletionCreateParams::Stop }, nil?: true
  245. # @!attribute store
  246. # Whether or not to store the output of this chat completion request for use in
  247. # our [model distillation](https://platform.openai.com/docs/guides/distillation)
  248. # or [evals](https://platform.openai.com/docs/guides/evals) products.
  249. #
  250. # Supports text and image inputs. Note: image inputs over 10MB will be dropped.
  251. #
  252. # @return [Boolean, nil]
  253. 1 optional :store, OpenAI::Internal::Type::Boolean, nil?: true
  254. # @!attribute stream_options
  255. # Options for streaming response. Only set this when you set `stream: true`.
  256. #
  257. # @return [OpenAI::Models::Chat::ChatCompletionStreamOptions, nil]
  258. 1 optional :stream_options, -> { OpenAI::Chat::ChatCompletionStreamOptions }, nil?: true
  259. # @!attribute temperature
  260. # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  261. # make the output more random, while lower values like 0.2 will make it more
  262. # focused and deterministic. We generally recommend altering this or `top_p` but
  263. # not both.
  264. #
  265. # @return [Float, nil]
  266. 1 optional :temperature, Float, nil?: true
  267. # @!attribute tool_choice
  268. # Controls which (if any) tool is called by the model. `none` means the model will
  269. # not call any tool and instead generates a message. `auto` means the model can
  270. # pick between generating a message or calling one or more tools. `required` means
  271. # the model must call one or more tools. Specifying a particular tool via
  272. # `{"type": "function", "function": {"name": "my_function"}}` forces the model to
  273. # call that tool.
  274. #
  275. # `none` is the default when no tools are present. `auto` is the default if tools
  276. # are present.
  277. #
  278. # @return [Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionNamedToolChoice, nil]
  279. 1 optional :tool_choice, union: -> { OpenAI::Chat::ChatCompletionToolChoiceOption }
  280. # @!attribute tools
  281. # A list of tools the model may call. Currently, only functions are supported as a
  282. # tool. Use this to provide a list of functions the model may generate JSON inputs
  283. # for. A max of 128 functions are supported.
  284. #
  285. # @return [Array<OpenAI::Models::Chat::ChatCompletionTool, OpenAI::StructuredOutput::JsonSchemaConverter>, nil]
  286. 1 optional :tools,
  287. -> {
  288. OpenAI::Internal::Type::ArrayOf[union: OpenAI::UnionOf[
  289. OpenAI::Chat::ChatCompletionTool, OpenAI::StructuredOutput::JsonSchemaConverter
  290. ]]
  291. }
  292. # @!attribute top_logprobs
  293. # An integer between 0 and 20 specifying the number of most likely tokens to
  294. # return at each token position, each with an associated log probability.
  295. # `logprobs` must be set to `true` if this parameter is used.
  296. #
  297. # @return [Integer, nil]
  298. 1 optional :top_logprobs, Integer, nil?: true
  299. # @!attribute top_p
  300. # An alternative to sampling with temperature, called nucleus sampling, where the
  301. # model considers the results of the tokens with top_p probability mass. So 0.1
  302. # means only the tokens comprising the top 10% probability mass are considered.
  303. #
  304. # We generally recommend altering this or `temperature` but not both.
  305. #
  306. # @return [Float, nil]
  307. 1 optional :top_p, Float, nil?: true
  308. # @!attribute user
  309. # @deprecated
  310. #
  311. # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  312. # `prompt_cache_key` instead to maintain caching optimizations. A stable
  313. # identifier for your end-users. Used to boost cache hit rates by better bucketing
  314. # similar requests and to help OpenAI detect and prevent abuse.
  315. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
  316. #
  317. # @return [String, nil]
  318. 1 optional :user, String
  319. # @!attribute web_search_options
  320. # This tool searches the web for relevant results to use in a response. Learn more
  321. # about the
  322. # [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
  323. #
  324. # @return [OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions, nil]
  325. 1 optional :web_search_options, -> { OpenAI::Chat::CompletionCreateParams::WebSearchOptions }
  326. # @!method initialize(messages:, model:, audio: nil, frequency_penalty: nil, function_call: nil, functions: nil, logit_bias: nil, logprobs: nil, max_completion_tokens: nil, max_tokens: nil, metadata: nil, modalities: nil, n: nil, parallel_tool_calls: nil, prediction: nil, presence_penalty: nil, prompt_cache_key: nil, reasoning_effort: nil, response_format: nil, safety_identifier: nil, seed: nil, service_tier: nil, stop: nil, store: nil, stream_options: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, user: nil, web_search_options: nil, request_options: {})
  327. # Some parameter documentations has been truncated, see
  328. # {OpenAI::Models::Chat::CompletionCreateParams} for more details.
  329. #
  330. # @param messages [Array<OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam>] A list of messages comprising the conversation so far. Depending on the
  331. #
  332. # @param model [String, Symbol, OpenAI::Models::ChatModel] Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
  333. #
  334. # @param audio [OpenAI::Models::Chat::ChatCompletionAudioParam, nil] Parameters for audio output. Required when audio output is requested with
  335. #
  336. # @param frequency_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on
  337. #
  338. # @param function_call [Symbol, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode, OpenAI::Models::Chat::ChatCompletionFunctionCallOption] Deprecated in favor of `tool_choice`.
  339. #
  340. # @param functions [Array<OpenAI::Models::Chat::CompletionCreateParams::Function>] Deprecated in favor of `tools`.
  341. #
  342. # @param logit_bias [Hash{Symbol=>Integer}, nil] Modify the likelihood of specified tokens appearing in the completion.
  343. #
  344. # @param logprobs [Boolean, nil] Whether to return log probabilities of the output tokens or not. If true,
  345. #
  346. # @param max_completion_tokens [Integer, nil] An upper bound for the number of tokens that can be generated for a completion,
  347. #
  348. # @param max_tokens [Integer, nil] The maximum number of [tokens](/tokenizer) that can be generated in the
  349. #
  350. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  351. #
  352. # @param modalities [Array<Symbol, OpenAI::Models::Chat::CompletionCreateParams::Modality>, nil] Output types that you would like the model to generate.
  353. #
  354. # @param n [Integer, nil] How many chat completion choices to generate for each input message. Note that y
  355. #
  356. # @param parallel_tool_calls [Boolean] Whether to enable [parallel function calling](https://platform.openai.com/docs/g
  357. #
  358. # @param prediction [OpenAI::Models::Chat::ChatCompletionPredictionContent, nil] Static predicted output content, such as the content of a text file that is
  359. #
  360. # @param presence_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on
  361. #
  362. # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi
  363. #
  364. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] **o-series models only**
  365. #
  366. # @param response_format [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::StructuredOutput::JsonSchemaConverter, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  367. #
  368. # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi
  369. #
  370. # @param seed [Integer, nil] This feature is in Beta.
  371. #
  372. # @param service_tier [Symbol, OpenAI::Models::Chat::CompletionCreateParams::ServiceTier, nil] Specifies the processing type used for serving the request.
  373. #
  374. # @param stop [String, Array<String>, nil] Not supported with latest reasoning models `o3` and `o4-mini`.
  375. #
  376. # @param store [Boolean, nil] Whether or not to store the output of this chat completion request for
  377. #
  378. # @param stream_options [OpenAI::Models::Chat::ChatCompletionStreamOptions, nil] Options for streaming response. Only set this when you set `stream: true`.
  379. #
  380. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  381. #
  382. # @param tool_choice [Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionNamedToolChoice] Controls which (if any) tool is called by the model.
  383. #
  384. # @param tools [Array<OpenAI::Models::Chat::ChatCompletionTool, OpenAI::StructuredOutput::JsonSchemaConverter>] A list of tools the model may call. Currently, only functions are supported as a
  385. #
  386. # @param top_logprobs [Integer, nil] An integer between 0 and 20 specifying the number of most likely tokens to
  387. #
  388. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling,
  389. #
  390. # @param user [String] This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  391. #
  392. # @param web_search_options [OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions] This tool searches the web for relevant results to use in a response.
  393. #
  394. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  395. # Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
  396. # wide range of models with different capabilities, performance characteristics,
  397. # and price points. Refer to the
  398. # [model guide](https://platform.openai.com/docs/models) to browse and compare
  399. # available models.
  400. 1 module Model
  401. 1 extend OpenAI::Internal::Type::Union
  402. 1 variant String
  403. # Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
  404. # offers a wide range of models with different capabilities, performance
  405. # characteristics, and price points. Refer to the [model guide](https://platform.openai.com/docs/models)
  406. # to browse and compare available models.
  407. 1 variant enum: -> { OpenAI::ChatModel }
  408. # @!method self.variants
  409. # @return [Array(String, Symbol, OpenAI::Models::ChatModel)]
  410. end
  411. # @deprecated
  412. #
  413. # Deprecated in favor of `tool_choice`.
  414. #
  415. # Controls which (if any) function is called by the model.
  416. #
  417. # `none` means the model will not call a function and instead generates a message.
  418. #
  419. # `auto` means the model can pick between generating a message or calling a
  420. # function.
  421. #
  422. # Specifying a particular function via `{"name": "my_function"}` forces the model
  423. # to call that function.
  424. #
  425. # `none` is the default when no functions are present. `auto` is the default if
  426. # functions are present.
  427. 1 module FunctionCall
  428. 1 extend OpenAI::Internal::Type::Union
  429. # `none` means the model will not call a function and instead generates a message. `auto` means the model can pick between generating a message or calling a function.
  430. 1 variant enum: -> { OpenAI::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode }
  431. # Specifying a particular function via `{"name": "my_function"}` forces the model to call that function.
  432. 1 variant -> { OpenAI::Chat::ChatCompletionFunctionCallOption }
  433. # `none` means the model will not call a function and instead generates a message.
  434. # `auto` means the model can pick between generating a message or calling a
  435. # function.
  436. 1 module FunctionCallMode
  437. 1 extend OpenAI::Internal::Type::Enum
  438. 1 NONE = :none
  439. 1 AUTO = :auto
  440. # @!method self.values
  441. # @return [Array<Symbol>]
  442. end
  443. # @!method self.variants
  444. # @return [Array(Symbol, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode, OpenAI::Models::Chat::ChatCompletionFunctionCallOption)]
  445. end
  446. # @deprecated
  447. 1 class Function < OpenAI::Internal::Type::BaseModel
  448. # @!attribute name
  449. # The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
  450. # underscores and dashes, with a maximum length of 64.
  451. #
  452. # @return [String]
  453. 1 required :name, String
  454. # @!attribute description
  455. # A description of what the function does, used by the model to choose when and
  456. # how to call the function.
  457. #
  458. # @return [String, nil]
  459. 1 optional :description, String
  460. # @!attribute parameters
  461. # The parameters the functions accepts, described as a JSON Schema object. See the
  462. # [guide](https://platform.openai.com/docs/guides/function-calling) for examples,
  463. # and the
  464. # [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
  465. # documentation about the format.
  466. #
  467. # Omitting `parameters` defines a function with an empty parameter list.
  468. #
  469. # @return [Hash{Symbol=>Object}, nil]
  470. 1 optional :parameters, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  471. # @!method initialize(name:, description: nil, parameters: nil)
  472. # Some parameter documentations has been truncated, see
  473. # {OpenAI::Models::Chat::CompletionCreateParams::Function} for more details.
  474. #
  475. # @param name [String] The name of the function to be called. Must be a-z, A-Z, 0-9, or contain undersc
  476. #
  477. # @param description [String] A description of what the function does, used by the model to choose when and ho
  478. #
  479. # @param parameters [Hash{Symbol=>Object}] The parameters the functions accepts, described as a JSON Schema object. See the
  480. end
  481. 1 module Modality
  482. 1 extend OpenAI::Internal::Type::Enum
  483. 1 TEXT = :text
  484. 1 AUDIO = :audio
  485. # @!method self.values
  486. # @return [Array<Symbol>]
  487. end
  488. # An object specifying the format that the model must output.
  489. #
  490. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  491. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  492. # in the
  493. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  494. #
  495. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  496. # ensures the message the model generates is valid JSON. Using `json_schema` is
  497. # preferred for models that support it.
  498. 1 module ResponseFormat
  499. 1 extend OpenAI::Internal::Type::Union
  500. # Default response format. Used to generate text responses.
  501. 1 variant -> { OpenAI::ResponseFormatText }
  502. # JSON Schema response format. Used to generate structured JSON responses.
  503. # Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
  504. 1 variant -> { OpenAI::ResponseFormatJSONSchema }
  505. # An {OpenAI::BaseModel} can be provided and implicitly converted into {OpenAI::Models::ResponseFormatJSONSchema}.
  506. # See examples for more details.
  507. #
  508. # Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
  509. 1 variant -> { OpenAI::StructuredOutput::JsonSchemaConverter }
  510. # JSON object response format. An older method of generating JSON responses.
  511. # Using `json_schema` is recommended for models that support it. Note that the
  512. # model will not generate JSON without a system or user message instructing it
  513. # to do so.
  514. 1 variant -> { OpenAI::ResponseFormatJSONObject }
  515. # @!method self.variants
  516. # @return [Array(OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject)]
  517. end
  518. # Specifies the processing type used for serving the request.
  519. #
  520. # - If set to 'auto', then the request will be processed with the service tier
  521. # configured in the Project settings. Unless otherwise configured, the Project
  522. # will use 'default'.
  523. # - If set to 'default', then the request will be processed with the standard
  524. # pricing and performance for the selected model.
  525. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  526. # 'priority', then the request will be processed with the corresponding service
  527. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  528. # Priority processing.
  529. # - When not set, the default behavior is 'auto'.
  530. #
  531. # When the `service_tier` parameter is set, the response body will include the
  532. # `service_tier` value based on the processing mode actually used to serve the
  533. # request. This response value may be different from the value set in the
  534. # parameter.
  535. 1 module ServiceTier
  536. 1 extend OpenAI::Internal::Type::Enum
  537. 1 AUTO = :auto
  538. 1 DEFAULT = :default
  539. 1 FLEX = :flex
  540. 1 SCALE = :scale
  541. 1 PRIORITY = :priority
  542. # @!method self.values
  543. # @return [Array<Symbol>]
  544. end
  545. # Not supported with latest reasoning models `o3` and `o4-mini`.
  546. #
  547. # Up to 4 sequences where the API will stop generating further tokens. The
  548. # returned text will not contain the stop sequence.
  549. 1 module Stop
  550. 1 extend OpenAI::Internal::Type::Union
  551. 1 variant String
  552. 1 variant -> { OpenAI::Models::Chat::CompletionCreateParams::Stop::StringArray }
  553. # @!method self.variants
  554. # @return [Array(String, Array<String>)]
  555. # @type [OpenAI::Internal::Type::Converter]
  556. 1 StringArray = OpenAI::Internal::Type::ArrayOf[String]
  557. end
  558. 1 class WebSearchOptions < OpenAI::Internal::Type::BaseModel
  559. # @!attribute search_context_size
  560. # High level guidance for the amount of context window space to use for the
  561. # search. One of `low`, `medium`, or `high`. `medium` is the default.
  562. #
  563. # @return [Symbol, OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize, nil]
  564. 1 optional :search_context_size,
  565. enum: -> { OpenAI::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize }
  566. # @!attribute user_location
  567. # Approximate location parameters for the search.
  568. #
  569. # @return [OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation, nil]
  570. 1 optional :user_location,
  571. -> { OpenAI::Chat::CompletionCreateParams::WebSearchOptions::UserLocation },
  572. nil?: true
  573. # @!method initialize(search_context_size: nil, user_location: nil)
  574. # Some parameter documentations has been truncated, see
  575. # {OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions} for more
  576. # details.
  577. #
  578. # This tool searches the web for relevant results to use in a response. Learn more
  579. # about the
  580. # [web search tool](https://platform.openai.com/docs/guides/tools-web-search?api-mode=chat).
  581. #
  582. # @param search_context_size [Symbol, OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::SearchContextSize] High level guidance for the amount of context window space to use for the
  583. #
  584. # @param user_location [OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation, nil] Approximate location parameters for the search.
  585. # High level guidance for the amount of context window space to use for the
  586. # search. One of `low`, `medium`, or `high`. `medium` is the default.
  587. #
  588. # @see OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions#search_context_size
  589. 1 module SearchContextSize
  590. 1 extend OpenAI::Internal::Type::Enum
  591. 1 LOW = :low
  592. 1 MEDIUM = :medium
  593. 1 HIGH = :high
  594. # @!method self.values
  595. # @return [Array<Symbol>]
  596. end
  597. # @see OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions#user_location
  598. 1 class UserLocation < OpenAI::Internal::Type::BaseModel
  599. # @!attribute approximate
  600. # Approximate location parameters for the search.
  601. #
  602. # @return [OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate]
  603. 1 required :approximate,
  604. -> { OpenAI::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate }
  605. # @!attribute type
  606. # The type of location approximation. Always `approximate`.
  607. #
  608. # @return [Symbol, :approximate]
  609. 1 required :type, const: :approximate
  610. # @!method initialize(approximate:, type: :approximate)
  611. # Some parameter documentations has been truncated, see
  612. # {OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation}
  613. # for more details.
  614. #
  615. # Approximate location parameters for the search.
  616. #
  617. # @param approximate [OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate] Approximate location parameters for the search.
  618. #
  619. # @param type [Symbol, :approximate] The type of location approximation. Always `approximate`.
  620. # @see OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation#approximate
  621. 1 class Approximate < OpenAI::Internal::Type::BaseModel
  622. # @!attribute city
  623. # Free text input for the city of the user, e.g. `San Francisco`.
  624. #
  625. # @return [String, nil]
  626. 1 optional :city, String
  627. # @!attribute country
  628. # The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
  629. # the user, e.g. `US`.
  630. #
  631. # @return [String, nil]
  632. 1 optional :country, String
  633. # @!attribute region
  634. # Free text input for the region of the user, e.g. `California`.
  635. #
  636. # @return [String, nil]
  637. 1 optional :region, String
  638. # @!attribute timezone
  639. # The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
  640. # user, e.g. `America/Los_Angeles`.
  641. #
  642. # @return [String, nil]
  643. 1 optional :timezone, String
  644. # @!method initialize(city: nil, country: nil, region: nil, timezone: nil)
  645. # Some parameter documentations has been truncated, see
  646. # {OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions::UserLocation::Approximate}
  647. # for more details.
  648. #
  649. # Approximate location parameters for the search.
  650. #
  651. # @param city [String] Free text input for the city of the user, e.g. `San Francisco`.
  652. #
  653. # @param country [String] The two-letter
  654. #
  655. # @param region [String] Free text input for the region of the user, e.g. `California`.
  656. #
  657. # @param timezone [String] The [IANA timezone](https://timeapi.io/documentation/iana-timezones)
  658. end
  659. end
  660. end
  661. end
  662. end
  663. end
  664. end

openai-ruby/lib/openai/models/chat/completion_delete_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # @see OpenAI::Resources::Chat::Completions#delete
  6. 1 class CompletionDeleteParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/chat/completion_list_params.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # @see OpenAI::Resources::Chat::Completions#list
  6. 1 class CompletionListParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute after
  10. # Identifier for the last chat completion from the previous pagination request.
  11. #
  12. # @return [String, nil]
  13. 1 optional :after, String
  14. # @!attribute limit
  15. # Number of Chat Completions to retrieve.
  16. #
  17. # @return [Integer, nil]
  18. 1 optional :limit, Integer
  19. # @!attribute metadata
  20. # A list of metadata keys to filter the Chat Completions by. Example:
  21. #
  22. # `metadata[key1]=value1&metadata[key2]=value2`
  23. #
  24. # @return [Hash{Symbol=>String}, nil]
  25. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  26. # @!attribute model
  27. # The model used to generate the Chat Completions.
  28. #
  29. # @return [String, nil]
  30. 1 optional :model, String
  31. # @!attribute order
  32. # Sort order for Chat Completions by timestamp. Use `asc` for ascending order or
  33. # `desc` for descending order. Defaults to `asc`.
  34. #
  35. # @return [Symbol, OpenAI::Models::Chat::CompletionListParams::Order, nil]
  36. 1 optional :order, enum: -> { OpenAI::Chat::CompletionListParams::Order }
  37. # @!method initialize(after: nil, limit: nil, metadata: nil, model: nil, order: nil, request_options: {})
  38. # Some parameter documentations has been truncated, see
  39. # {OpenAI::Models::Chat::CompletionListParams} for more details.
  40. #
  41. # @param after [String] Identifier for the last chat completion from the previous pagination request.
  42. #
  43. # @param limit [Integer] Number of Chat Completions to retrieve.
  44. #
  45. # @param metadata [Hash{Symbol=>String}, nil] A list of metadata keys to filter the Chat Completions by. Example:
  46. #
  47. # @param model [String] The model used to generate the Chat Completions.
  48. #
  49. # @param order [Symbol, OpenAI::Models::Chat::CompletionListParams::Order] Sort order for Chat Completions by timestamp. Use `asc` for ascending order or `
  50. #
  51. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  52. # Sort order for Chat Completions by timestamp. Use `asc` for ascending order or
  53. # `desc` for descending order. Defaults to `asc`.
  54. 1 module Order
  55. 1 extend OpenAI::Internal::Type::Enum
  56. 1 ASC = :asc
  57. 1 DESC = :desc
  58. # @!method self.values
  59. # @return [Array<Symbol>]
  60. end
  61. end
  62. end
  63. end
  64. end

openai-ruby/lib/openai/models/chat/completion_retrieve_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # @see OpenAI::Resources::Chat::Completions#retrieve
  6. 1 class CompletionRetrieveParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/chat/completion_update_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. # @see OpenAI::Resources::Chat::Completions#update
  6. 1 class CompletionUpdateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute metadata
  10. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  11. # for storing additional information about the object in a structured format, and
  12. # querying for objects via API or the dashboard.
  13. #
  14. # Keys are strings with a maximum length of 64 characters. Values are strings with
  15. # a maximum length of 512 characters.
  16. #
  17. # @return [Hash{Symbol=>String}, nil]
  18. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  19. # @!method initialize(metadata:, request_options: {})
  20. # Some parameter documentations has been truncated, see
  21. # {OpenAI::Models::Chat::CompletionUpdateParams} for more details.
  22. #
  23. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  24. #
  25. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  26. end
  27. end
  28. end
  29. end

openai-ruby/lib/openai/models/chat/completions/message_list_params.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Chat
  5. 1 module Completions
  6. # @see OpenAI::Resources::Chat::Completions::Messages#list
  7. 1 class MessageListParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute after
  11. # Identifier for the last message from the previous pagination request.
  12. #
  13. # @return [String, nil]
  14. 1 optional :after, String
  15. # @!attribute limit
  16. # Number of messages to retrieve.
  17. #
  18. # @return [Integer, nil]
  19. 1 optional :limit, Integer
  20. # @!attribute order
  21. # Sort order for messages by timestamp. Use `asc` for ascending order or `desc`
  22. # for descending order. Defaults to `asc`.
  23. #
  24. # @return [Symbol, OpenAI::Models::Chat::Completions::MessageListParams::Order, nil]
  25. 1 optional :order, enum: -> { OpenAI::Chat::Completions::MessageListParams::Order }
  26. # @!method initialize(after: nil, limit: nil, order: nil, request_options: {})
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Chat::Completions::MessageListParams} for more details.
  29. #
  30. # @param after [String] Identifier for the last message from the previous pagination request.
  31. #
  32. # @param limit [Integer] Number of messages to retrieve.
  33. #
  34. # @param order [Symbol, OpenAI::Models::Chat::Completions::MessageListParams::Order] Sort order for messages by timestamp. Use `asc` for ascending order or `desc` fo
  35. #
  36. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  37. # Sort order for messages by timestamp. Use `asc` for ascending order or `desc`
  38. # for descending order. Defaults to `asc`.
  39. 1 module Order
  40. 1 extend OpenAI::Internal::Type::Enum
  41. 1 ASC = :asc
  42. 1 DESC = :desc
  43. # @!method self.values
  44. # @return [Array<Symbol>]
  45. end
  46. end
  47. end
  48. end
  49. end
  50. end

openai-ruby/lib/openai/models/chat_model.rb

100.0% lines covered

100.0% branches covered

59 relevant lines. 59 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module ChatModel
  5. 1 extend OpenAI::Internal::Type::Enum
  6. 1 GPT_4_1 = :"gpt-4.1"
  7. 1 GPT_4_1_MINI = :"gpt-4.1-mini"
  8. 1 GPT_4_1_NANO = :"gpt-4.1-nano"
  9. 1 GPT_4_1_2025_04_14 = :"gpt-4.1-2025-04-14"
  10. 1 GPT_4_1_MINI_2025_04_14 = :"gpt-4.1-mini-2025-04-14"
  11. 1 GPT_4_1_NANO_2025_04_14 = :"gpt-4.1-nano-2025-04-14"
  12. 1 O4_MINI = :"o4-mini"
  13. 1 O4_MINI_2025_04_16 = :"o4-mini-2025-04-16"
  14. 1 O3 = :o3
  15. 1 O3_2025_04_16 = :"o3-2025-04-16"
  16. 1 O3_MINI = :"o3-mini"
  17. 1 O3_MINI_2025_01_31 = :"o3-mini-2025-01-31"
  18. 1 O1 = :o1
  19. 1 O1_2024_12_17 = :"o1-2024-12-17"
  20. 1 O1_PREVIEW = :"o1-preview"
  21. 1 O1_PREVIEW_2024_09_12 = :"o1-preview-2024-09-12"
  22. 1 O1_MINI = :"o1-mini"
  23. 1 O1_MINI_2024_09_12 = :"o1-mini-2024-09-12"
  24. 1 GPT_4O = :"gpt-4o"
  25. 1 GPT_4O_2024_11_20 = :"gpt-4o-2024-11-20"
  26. 1 GPT_4O_2024_08_06 = :"gpt-4o-2024-08-06"
  27. 1 GPT_4O_2024_05_13 = :"gpt-4o-2024-05-13"
  28. 1 GPT_4O_AUDIO_PREVIEW = :"gpt-4o-audio-preview"
  29. 1 GPT_4O_AUDIO_PREVIEW_2024_10_01 = :"gpt-4o-audio-preview-2024-10-01"
  30. 1 GPT_4O_AUDIO_PREVIEW_2024_12_17 = :"gpt-4o-audio-preview-2024-12-17"
  31. 1 GPT_4O_AUDIO_PREVIEW_2025_06_03 = :"gpt-4o-audio-preview-2025-06-03"
  32. 1 GPT_4O_MINI_AUDIO_PREVIEW = :"gpt-4o-mini-audio-preview"
  33. 1 GPT_4O_MINI_AUDIO_PREVIEW_2024_12_17 = :"gpt-4o-mini-audio-preview-2024-12-17"
  34. 1 GPT_4O_SEARCH_PREVIEW = :"gpt-4o-search-preview"
  35. 1 GPT_4O_MINI_SEARCH_PREVIEW = :"gpt-4o-mini-search-preview"
  36. 1 GPT_4O_SEARCH_PREVIEW_2025_03_11 = :"gpt-4o-search-preview-2025-03-11"
  37. 1 GPT_4O_MINI_SEARCH_PREVIEW_2025_03_11 = :"gpt-4o-mini-search-preview-2025-03-11"
  38. 1 CHATGPT_4O_LATEST = :"chatgpt-4o-latest"
  39. 1 CODEX_MINI_LATEST = :"codex-mini-latest"
  40. 1 GPT_4O_MINI = :"gpt-4o-mini"
  41. 1 GPT_4O_MINI_2024_07_18 = :"gpt-4o-mini-2024-07-18"
  42. 1 GPT_4_TURBO = :"gpt-4-turbo"
  43. 1 GPT_4_TURBO_2024_04_09 = :"gpt-4-turbo-2024-04-09"
  44. 1 GPT_4_0125_PREVIEW = :"gpt-4-0125-preview"
  45. 1 GPT_4_TURBO_PREVIEW = :"gpt-4-turbo-preview"
  46. 1 GPT_4_1106_PREVIEW = :"gpt-4-1106-preview"
  47. 1 GPT_4_VISION_PREVIEW = :"gpt-4-vision-preview"
  48. 1 GPT_4 = :"gpt-4"
  49. 1 GPT_4_0314 = :"gpt-4-0314"
  50. 1 GPT_4_0613 = :"gpt-4-0613"
  51. 1 GPT_4_32K = :"gpt-4-32k"
  52. 1 GPT_4_32K_0314 = :"gpt-4-32k-0314"
  53. 1 GPT_4_32K_0613 = :"gpt-4-32k-0613"
  54. 1 GPT_3_5_TURBO = :"gpt-3.5-turbo"
  55. 1 GPT_3_5_TURBO_16K = :"gpt-3.5-turbo-16k"
  56. 1 GPT_3_5_TURBO_0301 = :"gpt-3.5-turbo-0301"
  57. 1 GPT_3_5_TURBO_0613 = :"gpt-3.5-turbo-0613"
  58. 1 GPT_3_5_TURBO_1106 = :"gpt-3.5-turbo-1106"
  59. 1 GPT_3_5_TURBO_0125 = :"gpt-3.5-turbo-0125"
  60. 1 GPT_3_5_TURBO_16K_0613 = :"gpt-3.5-turbo-16k-0613"
  61. # @!method self.values
  62. # @return [Array<Symbol>]
  63. end
  64. end
  65. end

openai-ruby/lib/openai/models/comparison_filter.rb

100.0% lines covered

100.0% branches covered

19 relevant lines. 19 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ComparisonFilter < OpenAI::Internal::Type::BaseModel
  5. # @!attribute key
  6. # The key to compare against the value.
  7. #
  8. # @return [String]
  9. 1 required :key, String
  10. # @!attribute type
  11. # Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`.
  12. #
  13. # - `eq`: equals
  14. # - `ne`: not equal
  15. # - `gt`: greater than
  16. # - `gte`: greater than or equal
  17. # - `lt`: less than
  18. # - `lte`: less than or equal
  19. #
  20. # @return [Symbol, OpenAI::Models::ComparisonFilter::Type]
  21. 1 required :type, enum: -> { OpenAI::ComparisonFilter::Type }
  22. # @!attribute value
  23. # The value to compare against the attribute key; supports string, number, or
  24. # boolean types.
  25. #
  26. # @return [String, Float, Boolean]
  27. 1 required :value, union: -> { OpenAI::ComparisonFilter::Value }
  28. # @!method initialize(key:, type:, value:)
  29. # Some parameter documentations has been truncated, see
  30. # {OpenAI::Models::ComparisonFilter} for more details.
  31. #
  32. # A filter used to compare a specified attribute key to a given value using a
  33. # defined comparison operation.
  34. #
  35. # @param key [String] The key to compare against the value.
  36. #
  37. # @param type [Symbol, OpenAI::Models::ComparisonFilter::Type] Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`.
  38. #
  39. # @param value [String, Float, Boolean] The value to compare against the attribute key; supports string, number, or bool
  40. # Specifies the comparison operator: `eq`, `ne`, `gt`, `gte`, `lt`, `lte`.
  41. #
  42. # - `eq`: equals
  43. # - `ne`: not equal
  44. # - `gt`: greater than
  45. # - `gte`: greater than or equal
  46. # - `lt`: less than
  47. # - `lte`: less than or equal
  48. #
  49. # @see OpenAI::Models::ComparisonFilter#type
  50. 1 module Type
  51. 1 extend OpenAI::Internal::Type::Enum
  52. 1 EQ = :eq
  53. 1 NE = :ne
  54. 1 GT = :gt
  55. 1 GTE = :gte
  56. 1 LT = :lt
  57. 1 LTE = :lte
  58. # @!method self.values
  59. # @return [Array<Symbol>]
  60. end
  61. # The value to compare against the attribute key; supports string, number, or
  62. # boolean types.
  63. #
  64. # @see OpenAI::Models::ComparisonFilter#value
  65. 1 module Value
  66. 1 extend OpenAI::Internal::Type::Union
  67. 1 variant String
  68. 1 variant Float
  69. 1 variant OpenAI::Internal::Type::Boolean
  70. # @!method self.variants
  71. # @return [Array(String, Float, Boolean)]
  72. end
  73. end
  74. end
  75. end

openai-ruby/lib/openai/models/completion.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Completions#create
  5. #
  6. # @see OpenAI::Resources::Completions#create_streaming
  7. 1 class Completion < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # A unique identifier for the completion.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute choices
  14. # The list of completion choices the model generated for the input prompt.
  15. #
  16. # @return [Array<OpenAI::Models::CompletionChoice>]
  17. 1 required :choices, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::CompletionChoice] }
  18. # @!attribute created
  19. # The Unix timestamp (in seconds) of when the completion was created.
  20. #
  21. # @return [Integer]
  22. 1 required :created, Integer
  23. # @!attribute model
  24. # The model used for completion.
  25. #
  26. # @return [String]
  27. 1 required :model, String
  28. # @!attribute object
  29. # The object type, which is always "text_completion"
  30. #
  31. # @return [Symbol, :text_completion]
  32. 1 required :object, const: :text_completion
  33. # @!attribute system_fingerprint
  34. # This fingerprint represents the backend configuration that the model runs with.
  35. #
  36. # Can be used in conjunction with the `seed` request parameter to understand when
  37. # backend changes have been made that might impact determinism.
  38. #
  39. # @return [String, nil]
  40. 1 optional :system_fingerprint, String
  41. # @!attribute usage
  42. # Usage statistics for the completion request.
  43. #
  44. # @return [OpenAI::Models::CompletionUsage, nil]
  45. 1 optional :usage, -> { OpenAI::CompletionUsage }
  46. # @!method initialize(id:, choices:, created:, model:, system_fingerprint: nil, usage: nil, object: :text_completion)
  47. # Some parameter documentations has been truncated, see
  48. # {OpenAI::Models::Completion} for more details.
  49. #
  50. # Represents a completion response from the API. Note: both the streamed and
  51. # non-streamed response objects share the same shape (unlike the chat endpoint).
  52. #
  53. # @param id [String] A unique identifier for the completion.
  54. #
  55. # @param choices [Array<OpenAI::Models::CompletionChoice>] The list of completion choices the model generated for the input prompt.
  56. #
  57. # @param created [Integer] The Unix timestamp (in seconds) of when the completion was created.
  58. #
  59. # @param model [String] The model used for completion.
  60. #
  61. # @param system_fingerprint [String] This fingerprint represents the backend configuration that the model runs with.
  62. #
  63. # @param usage [OpenAI::Models::CompletionUsage] Usage statistics for the completion request.
  64. #
  65. # @param object [Symbol, :text_completion] The object type, which is always "text_completion"
  66. end
  67. end
  68. end

openai-ruby/lib/openai/models/completion_choice.rb

100.0% lines covered

100.0% branches covered

17 relevant lines. 17 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class CompletionChoice < OpenAI::Internal::Type::BaseModel
  5. # @!attribute finish_reason
  6. # The reason the model stopped generating tokens. This will be `stop` if the model
  7. # hit a natural stop point or a provided stop sequence, `length` if the maximum
  8. # number of tokens specified in the request was reached, or `content_filter` if
  9. # content was omitted due to a flag from our content filters.
  10. #
  11. # @return [Symbol, OpenAI::Models::CompletionChoice::FinishReason]
  12. 1 required :finish_reason, enum: -> { OpenAI::CompletionChoice::FinishReason }
  13. # @!attribute index
  14. #
  15. # @return [Integer]
  16. 1 required :index, Integer
  17. # @!attribute logprobs
  18. #
  19. # @return [OpenAI::Models::CompletionChoice::Logprobs, nil]
  20. 1 required :logprobs, -> { OpenAI::CompletionChoice::Logprobs }, nil?: true
  21. # @!attribute text
  22. #
  23. # @return [String]
  24. 1 required :text, String
  25. # @!method initialize(finish_reason:, index:, logprobs:, text:)
  26. # Some parameter documentations has been truncated, see
  27. # {OpenAI::Models::CompletionChoice} for more details.
  28. #
  29. # @param finish_reason [Symbol, OpenAI::Models::CompletionChoice::FinishReason] The reason the model stopped generating tokens. This will be `stop` if the model
  30. #
  31. # @param index [Integer]
  32. #
  33. # @param logprobs [OpenAI::Models::CompletionChoice::Logprobs, nil]
  34. #
  35. # @param text [String]
  36. # The reason the model stopped generating tokens. This will be `stop` if the model
  37. # hit a natural stop point or a provided stop sequence, `length` if the maximum
  38. # number of tokens specified in the request was reached, or `content_filter` if
  39. # content was omitted due to a flag from our content filters.
  40. #
  41. # @see OpenAI::Models::CompletionChoice#finish_reason
  42. 1 module FinishReason
  43. 1 extend OpenAI::Internal::Type::Enum
  44. 1 STOP = :stop
  45. 1 LENGTH = :length
  46. 1 CONTENT_FILTER = :content_filter
  47. # @!method self.values
  48. # @return [Array<Symbol>]
  49. end
  50. # @see OpenAI::Models::CompletionChoice#logprobs
  51. 1 class Logprobs < OpenAI::Internal::Type::BaseModel
  52. # @!attribute text_offset
  53. #
  54. # @return [Array<Integer>, nil]
  55. 1 optional :text_offset, OpenAI::Internal::Type::ArrayOf[Integer]
  56. # @!attribute token_logprobs
  57. #
  58. # @return [Array<Float>, nil]
  59. 1 optional :token_logprobs, OpenAI::Internal::Type::ArrayOf[Float]
  60. # @!attribute tokens
  61. #
  62. # @return [Array<String>, nil]
  63. 1 optional :tokens, OpenAI::Internal::Type::ArrayOf[String]
  64. # @!attribute top_logprobs
  65. #
  66. # @return [Array<Hash{Symbol=>Float}>, nil]
  67. 1 optional :top_logprobs, OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::HashOf[Float]]
  68. # @!method initialize(text_offset: nil, token_logprobs: nil, tokens: nil, top_logprobs: nil)
  69. # @param text_offset [Array<Integer>]
  70. # @param token_logprobs [Array<Float>]
  71. # @param tokens [Array<String>]
  72. # @param top_logprobs [Array<Hash{Symbol=>Float}>]
  73. end
  74. end
  75. end
  76. end

openai-ruby/lib/openai/models/completion_create_params.rb

97.87% lines covered

100.0% branches covered

47 relevant lines. 46 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Completions#create
  5. #
  6. # @see OpenAI::Resources::Completions#create_streaming
  7. 1 class CompletionCreateParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute model
  11. # ID of the model to use. You can use the
  12. # [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  13. # see all of your available models, or see our
  14. # [Model overview](https://platform.openai.com/docs/models) for descriptions of
  15. # them.
  16. #
  17. # @return [String, Symbol, OpenAI::Models::CompletionCreateParams::Model]
  18. 1 required :model, union: -> { OpenAI::CompletionCreateParams::Model }
  19. # @!attribute prompt
  20. # The prompt(s) to generate completions for, encoded as a string, array of
  21. # strings, array of tokens, or array of token arrays.
  22. #
  23. # Note that <|endoftext|> is the document separator that the model sees during
  24. # training, so if a prompt is not specified the model will generate as if from the
  25. # beginning of a new document.
  26. #
  27. # @return [String, Array<String>, Array<Integer>, Array<Array<Integer>>, nil]
  28. 1 required :prompt, union: -> { OpenAI::CompletionCreateParams::Prompt }, nil?: true
  29. # @!attribute best_of
  30. # Generates `best_of` completions server-side and returns the "best" (the one with
  31. # the highest log probability per token). Results cannot be streamed.
  32. #
  33. # When used with `n`, `best_of` controls the number of candidate completions and
  34. # `n` specifies how many to return – `best_of` must be greater than `n`.
  35. #
  36. # **Note:** Because this parameter generates many completions, it can quickly
  37. # consume your token quota. Use carefully and ensure that you have reasonable
  38. # settings for `max_tokens` and `stop`.
  39. #
  40. # @return [Integer, nil]
  41. 1 optional :best_of, Integer, nil?: true
  42. # @!attribute echo
  43. # Echo back the prompt in addition to the completion
  44. #
  45. # @return [Boolean, nil]
  46. 1 optional :echo, OpenAI::Internal::Type::Boolean, nil?: true
  47. # @!attribute frequency_penalty
  48. # Number between -2.0 and 2.0. Positive values penalize new tokens based on their
  49. # existing frequency in the text so far, decreasing the model's likelihood to
  50. # repeat the same line verbatim.
  51. #
  52. # [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
  53. #
  54. # @return [Float, nil]
  55. 1 optional :frequency_penalty, Float, nil?: true
  56. # @!attribute logit_bias
  57. # Modify the likelihood of specified tokens appearing in the completion.
  58. #
  59. # Accepts a JSON object that maps tokens (specified by their token ID in the GPT
  60. # tokenizer) to an associated bias value from -100 to 100. You can use this
  61. # [tokenizer tool](/tokenizer?view=bpe) to convert text to token IDs.
  62. # Mathematically, the bias is added to the logits generated by the model prior to
  63. # sampling. The exact effect will vary per model, but values between -1 and 1
  64. # should decrease or increase likelihood of selection; values like -100 or 100
  65. # should result in a ban or exclusive selection of the relevant token.
  66. #
  67. # As an example, you can pass `{"50256": -100}` to prevent the <|endoftext|> token
  68. # from being generated.
  69. #
  70. # @return [Hash{Symbol=>Integer}, nil]
  71. 1 optional :logit_bias, OpenAI::Internal::Type::HashOf[Integer], nil?: true
  72. # @!attribute logprobs
  73. # Include the log probabilities on the `logprobs` most likely output tokens, as
  74. # well the chosen tokens. For example, if `logprobs` is 5, the API will return a
  75. # list of the 5 most likely tokens. The API will always return the `logprob` of
  76. # the sampled token, so there may be up to `logprobs+1` elements in the response.
  77. #
  78. # The maximum value for `logprobs` is 5.
  79. #
  80. # @return [Integer, nil]
  81. 1 optional :logprobs, Integer, nil?: true
  82. # @!attribute max_tokens
  83. # The maximum number of [tokens](/tokenizer) that can be generated in the
  84. # completion.
  85. #
  86. # The token count of your prompt plus `max_tokens` cannot exceed the model's
  87. # context length.
  88. # [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
  89. # for counting tokens.
  90. #
  91. # @return [Integer, nil]
  92. 1 optional :max_tokens, Integer, nil?: true
  93. # @!attribute n
  94. # How many completions to generate for each prompt.
  95. #
  96. # **Note:** Because this parameter generates many completions, it can quickly
  97. # consume your token quota. Use carefully and ensure that you have reasonable
  98. # settings for `max_tokens` and `stop`.
  99. #
  100. # @return [Integer, nil]
  101. 1 optional :n, Integer, nil?: true
  102. # @!attribute presence_penalty
  103. # Number between -2.0 and 2.0. Positive values penalize new tokens based on
  104. # whether they appear in the text so far, increasing the model's likelihood to
  105. # talk about new topics.
  106. #
  107. # [See more information about frequency and presence penalties.](https://platform.openai.com/docs/guides/text-generation)
  108. #
  109. # @return [Float, nil]
  110. 1 optional :presence_penalty, Float, nil?: true
  111. # @!attribute seed
  112. # If specified, our system will make a best effort to sample deterministically,
  113. # such that repeated requests with the same `seed` and parameters should return
  114. # the same result.
  115. #
  116. # Determinism is not guaranteed, and you should refer to the `system_fingerprint`
  117. # response parameter to monitor changes in the backend.
  118. #
  119. # @return [Integer, nil]
  120. 1 optional :seed, Integer, nil?: true
  121. # @!attribute stop
  122. # Not supported with latest reasoning models `o3` and `o4-mini`.
  123. #
  124. # Up to 4 sequences where the API will stop generating further tokens. The
  125. # returned text will not contain the stop sequence.
  126. #
  127. # @return [String, Array<String>, nil]
  128. 1 optional :stop, union: -> { OpenAI::CompletionCreateParams::Stop }, nil?: true
  129. # @!attribute stream_options
  130. # Options for streaming response. Only set this when you set `stream: true`.
  131. #
  132. # @return [OpenAI::Models::Chat::ChatCompletionStreamOptions, nil]
  133. 1 optional :stream_options, -> { OpenAI::Chat::ChatCompletionStreamOptions }, nil?: true
  134. # @!attribute suffix
  135. # The suffix that comes after a completion of inserted text.
  136. #
  137. # This parameter is only supported for `gpt-3.5-turbo-instruct`.
  138. #
  139. # @return [String, nil]
  140. 1 optional :suffix, String, nil?: true
  141. # @!attribute temperature
  142. # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  143. # make the output more random, while lower values like 0.2 will make it more
  144. # focused and deterministic.
  145. #
  146. # We generally recommend altering this or `top_p` but not both.
  147. #
  148. # @return [Float, nil]
  149. 1 optional :temperature, Float, nil?: true
  150. # @!attribute top_p
  151. # An alternative to sampling with temperature, called nucleus sampling, where the
  152. # model considers the results of the tokens with top_p probability mass. So 0.1
  153. # means only the tokens comprising the top 10% probability mass are considered.
  154. #
  155. # We generally recommend altering this or `temperature` but not both.
  156. #
  157. # @return [Float, nil]
  158. 1 optional :top_p, Float, nil?: true
  159. # @!attribute user
  160. # A unique identifier representing your end-user, which can help OpenAI to monitor
  161. # and detect abuse.
  162. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
  163. #
  164. # @return [String, nil]
  165. 1 optional :user, String
  166. # @!method initialize(model:, prompt:, best_of: nil, echo: nil, frequency_penalty: nil, logit_bias: nil, logprobs: nil, max_tokens: nil, n: nil, presence_penalty: nil, seed: nil, stop: nil, stream_options: nil, suffix: nil, temperature: nil, top_p: nil, user: nil, request_options: {})
  167. # Some parameter documentations has been truncated, see
  168. # {OpenAI::Models::CompletionCreateParams} for more details.
  169. #
  170. # @param model [String, Symbol, OpenAI::Models::CompletionCreateParams::Model] ID of the model to use. You can use the [List models](https://platform.openai.co
  171. #
  172. # @param prompt [String, Array<String>, Array<Integer>, Array<Array<Integer>>, nil] The prompt(s) to generate completions for, encoded as a string, array of strings
  173. #
  174. # @param best_of [Integer, nil] Generates `best_of` completions server-side and returns the "best" (the one with
  175. #
  176. # @param echo [Boolean, nil] Echo back the prompt in addition to the completion
  177. #
  178. # @param frequency_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on their
  179. #
  180. # @param logit_bias [Hash{Symbol=>Integer}, nil] Modify the likelihood of specified tokens appearing in the completion.
  181. #
  182. # @param logprobs [Integer, nil] Include the log probabilities on the `logprobs` most likely output tokens, as we
  183. #
  184. # @param max_tokens [Integer, nil] The maximum number of [tokens](/tokenizer) that can be generated in the completi
  185. #
  186. # @param n [Integer, nil] How many completions to generate for each prompt.
  187. #
  188. # @param presence_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on whethe
  189. #
  190. # @param seed [Integer, nil] If specified, our system will make a best effort to sample deterministically, su
  191. #
  192. # @param stop [String, Array<String>, nil] Not supported with latest reasoning models `o3` and `o4-mini`.
  193. #
  194. # @param stream_options [OpenAI::Models::Chat::ChatCompletionStreamOptions, nil] Options for streaming response. Only set this when you set `stream: true`.
  195. #
  196. # @param suffix [String, nil] The suffix that comes after a completion of inserted text.
  197. #
  198. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  199. #
  200. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  201. #
  202. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  203. #
  204. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  205. # ID of the model to use. You can use the
  206. # [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  207. # see all of your available models, or see our
  208. # [Model overview](https://platform.openai.com/docs/models) for descriptions of
  209. # them.
  210. 1 module Model
  211. 1 extend OpenAI::Internal::Type::Union
  212. 1 variant String
  213. 1 variant const: -> { OpenAI::Models::CompletionCreateParams::Model::GPT_3_5_TURBO_INSTRUCT }
  214. 1 variant const: -> { OpenAI::Models::CompletionCreateParams::Model::DAVINCI_002 }
  215. 1 variant const: -> { OpenAI::Models::CompletionCreateParams::Model::BABBAGE_002 }
  216. # @!method self.variants
  217. # @return [Array(String, Symbol)]
  218. 1 define_sorbet_constant!(:Variants) do
  219. T.type_alias { T.any(String, OpenAI::CompletionCreateParams::Model::TaggedSymbol) }
  220. end
  221. # @!group
  222. 1 GPT_3_5_TURBO_INSTRUCT = :"gpt-3.5-turbo-instruct"
  223. 1 DAVINCI_002 = :"davinci-002"
  224. 1 BABBAGE_002 = :"babbage-002"
  225. # @!endgroup
  226. end
  227. # The prompt(s) to generate completions for, encoded as a string, array of
  228. # strings, array of tokens, or array of token arrays.
  229. #
  230. # Note that <|endoftext|> is the document separator that the model sees during
  231. # training, so if a prompt is not specified the model will generate as if from the
  232. # beginning of a new document.
  233. 1 module Prompt
  234. 1 extend OpenAI::Internal::Type::Union
  235. 1 variant String
  236. 1 variant -> { OpenAI::Models::CompletionCreateParams::Prompt::StringArray }
  237. 1 variant -> { OpenAI::Models::CompletionCreateParams::Prompt::IntegerArray }
  238. 1 variant -> { OpenAI::Models::CompletionCreateParams::Prompt::ArrayOfToken2DArray }
  239. # @!method self.variants
  240. # @return [Array(String, Array<String>, Array<Integer>, Array<Array<Integer>>)]
  241. # @type [OpenAI::Internal::Type::Converter]
  242. 1 StringArray = OpenAI::Internal::Type::ArrayOf[String]
  243. # @type [OpenAI::Internal::Type::Converter]
  244. 1 IntegerArray = OpenAI::Internal::Type::ArrayOf[Integer]
  245. # @type [OpenAI::Internal::Type::Converter]
  246. 1 ArrayOfToken2DArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::ArrayOf[Integer]]
  247. end
  248. # Not supported with latest reasoning models `o3` and `o4-mini`.
  249. #
  250. # Up to 4 sequences where the API will stop generating further tokens. The
  251. # returned text will not contain the stop sequence.
  252. 1 module Stop
  253. 1 extend OpenAI::Internal::Type::Union
  254. 1 variant String
  255. 1 variant -> { OpenAI::Models::CompletionCreateParams::Stop::StringArray }
  256. # @!method self.variants
  257. # @return [Array(String, Array<String>)]
  258. # @type [OpenAI::Internal::Type::Converter]
  259. 1 StringArray = OpenAI::Internal::Type::ArrayOf[String]
  260. end
  261. end
  262. end
  263. end

openai-ruby/lib/openai/models/completion_usage.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class CompletionUsage < OpenAI::Internal::Type::BaseModel
  5. # @!attribute completion_tokens
  6. # Number of tokens in the generated completion.
  7. #
  8. # @return [Integer]
  9. 1 required :completion_tokens, Integer
  10. # @!attribute prompt_tokens
  11. # Number of tokens in the prompt.
  12. #
  13. # @return [Integer]
  14. 1 required :prompt_tokens, Integer
  15. # @!attribute total_tokens
  16. # Total number of tokens used in the request (prompt + completion).
  17. #
  18. # @return [Integer]
  19. 1 required :total_tokens, Integer
  20. # @!attribute completion_tokens_details
  21. # Breakdown of tokens used in a completion.
  22. #
  23. # @return [OpenAI::Models::CompletionUsage::CompletionTokensDetails, nil]
  24. 1 optional :completion_tokens_details, -> { OpenAI::CompletionUsage::CompletionTokensDetails }
  25. # @!attribute prompt_tokens_details
  26. # Breakdown of tokens used in the prompt.
  27. #
  28. # @return [OpenAI::Models::CompletionUsage::PromptTokensDetails, nil]
  29. 1 optional :prompt_tokens_details, -> { OpenAI::CompletionUsage::PromptTokensDetails }
  30. # @!method initialize(completion_tokens:, prompt_tokens:, total_tokens:, completion_tokens_details: nil, prompt_tokens_details: nil)
  31. # Usage statistics for the completion request.
  32. #
  33. # @param completion_tokens [Integer] Number of tokens in the generated completion.
  34. #
  35. # @param prompt_tokens [Integer] Number of tokens in the prompt.
  36. #
  37. # @param total_tokens [Integer] Total number of tokens used in the request (prompt + completion).
  38. #
  39. # @param completion_tokens_details [OpenAI::Models::CompletionUsage::CompletionTokensDetails] Breakdown of tokens used in a completion.
  40. #
  41. # @param prompt_tokens_details [OpenAI::Models::CompletionUsage::PromptTokensDetails] Breakdown of tokens used in the prompt.
  42. # @see OpenAI::Models::CompletionUsage#completion_tokens_details
  43. 1 class CompletionTokensDetails < OpenAI::Internal::Type::BaseModel
  44. # @!attribute accepted_prediction_tokens
  45. # When using Predicted Outputs, the number of tokens in the prediction that
  46. # appeared in the completion.
  47. #
  48. # @return [Integer, nil]
  49. 1 optional :accepted_prediction_tokens, Integer
  50. # @!attribute audio_tokens
  51. # Audio input tokens generated by the model.
  52. #
  53. # @return [Integer, nil]
  54. 1 optional :audio_tokens, Integer
  55. # @!attribute reasoning_tokens
  56. # Tokens generated by the model for reasoning.
  57. #
  58. # @return [Integer, nil]
  59. 1 optional :reasoning_tokens, Integer
  60. # @!attribute rejected_prediction_tokens
  61. # When using Predicted Outputs, the number of tokens in the prediction that did
  62. # not appear in the completion. However, like reasoning tokens, these tokens are
  63. # still counted in the total completion tokens for purposes of billing, output,
  64. # and context window limits.
  65. #
  66. # @return [Integer, nil]
  67. 1 optional :rejected_prediction_tokens, Integer
  68. # @!method initialize(accepted_prediction_tokens: nil, audio_tokens: nil, reasoning_tokens: nil, rejected_prediction_tokens: nil)
  69. # Some parameter documentations has been truncated, see
  70. # {OpenAI::Models::CompletionUsage::CompletionTokensDetails} for more details.
  71. #
  72. # Breakdown of tokens used in a completion.
  73. #
  74. # @param accepted_prediction_tokens [Integer] When using Predicted Outputs, the number of tokens in the
  75. #
  76. # @param audio_tokens [Integer] Audio input tokens generated by the model.
  77. #
  78. # @param reasoning_tokens [Integer] Tokens generated by the model for reasoning.
  79. #
  80. # @param rejected_prediction_tokens [Integer] When using Predicted Outputs, the number of tokens in the
  81. end
  82. # @see OpenAI::Models::CompletionUsage#prompt_tokens_details
  83. 1 class PromptTokensDetails < OpenAI::Internal::Type::BaseModel
  84. # @!attribute audio_tokens
  85. # Audio input tokens present in the prompt.
  86. #
  87. # @return [Integer, nil]
  88. 1 optional :audio_tokens, Integer
  89. # @!attribute cached_tokens
  90. # Cached tokens present in the prompt.
  91. #
  92. # @return [Integer, nil]
  93. 1 optional :cached_tokens, Integer
  94. # @!method initialize(audio_tokens: nil, cached_tokens: nil)
  95. # Breakdown of tokens used in the prompt.
  96. #
  97. # @param audio_tokens [Integer] Audio input tokens present in the prompt.
  98. #
  99. # @param cached_tokens [Integer] Cached tokens present in the prompt.
  100. end
  101. end
  102. end
  103. end

openai-ruby/lib/openai/models/compound_filter.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class CompoundFilter < OpenAI::Internal::Type::BaseModel
  5. # @!attribute filters
  6. # Array of filters to combine. Items can be `ComparisonFilter` or
  7. # `CompoundFilter`.
  8. #
  9. # @return [Array<OpenAI::Models::ComparisonFilter, Object>]
  10. 1 required :filters, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::CompoundFilter::Filter] }
  11. # @!attribute type
  12. # Type of operation: `and` or `or`.
  13. #
  14. # @return [Symbol, OpenAI::Models::CompoundFilter::Type]
  15. 1 required :type, enum: -> { OpenAI::CompoundFilter::Type }
  16. # @!method initialize(filters:, type:)
  17. # Some parameter documentations has been truncated, see
  18. # {OpenAI::Models::CompoundFilter} for more details.
  19. #
  20. # Combine multiple filters using `and` or `or`.
  21. #
  22. # @param filters [Array<OpenAI::Models::ComparisonFilter, Object>] Array of filters to combine. Items can be `ComparisonFilter` or `CompoundFilter`
  23. #
  24. # @param type [Symbol, OpenAI::Models::CompoundFilter::Type] Type of operation: `and` or `or`.
  25. # A filter used to compare a specified attribute key to a given value using a
  26. # defined comparison operation.
  27. 1 module Filter
  28. 1 extend OpenAI::Internal::Type::Union
  29. # A filter used to compare a specified attribute key to a given value using a defined comparison operation.
  30. 1 variant -> { OpenAI::ComparisonFilter }
  31. 1 variant OpenAI::Internal::Type::Unknown
  32. # @!method self.variants
  33. # @return [Array(OpenAI::Models::ComparisonFilter, Object)]
  34. end
  35. # Type of operation: `and` or `or`.
  36. #
  37. # @see OpenAI::Models::CompoundFilter#type
  38. 1 module Type
  39. 1 extend OpenAI::Internal::Type::Enum
  40. 1 AND = :and
  41. 1 OR = :or
  42. # @!method self.values
  43. # @return [Array<Symbol>]
  44. end
  45. end
  46. end
  47. end

openai-ruby/lib/openai/models/container_create_params.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Containers#create
  5. 1 class ContainerCreateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute name
  9. # Name of the container to create.
  10. #
  11. # @return [String]
  12. 1 required :name, String
  13. # @!attribute expires_after
  14. # Container expiration time in seconds relative to the 'anchor' time.
  15. #
  16. # @return [OpenAI::Models::ContainerCreateParams::ExpiresAfter, nil]
  17. 1 optional :expires_after, -> { OpenAI::ContainerCreateParams::ExpiresAfter }
  18. # @!attribute file_ids
  19. # IDs of files to copy to the container.
  20. #
  21. # @return [Array<String>, nil]
  22. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  23. # @!method initialize(name:, expires_after: nil, file_ids: nil, request_options: {})
  24. # @param name [String] Name of the container to create.
  25. #
  26. # @param expires_after [OpenAI::Models::ContainerCreateParams::ExpiresAfter] Container expiration time in seconds relative to the 'anchor' time.
  27. #
  28. # @param file_ids [Array<String>] IDs of files to copy to the container.
  29. #
  30. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  31. 1 class ExpiresAfter < OpenAI::Internal::Type::BaseModel
  32. # @!attribute anchor
  33. # Time anchor for the expiration time. Currently only 'last_active_at' is
  34. # supported.
  35. #
  36. # @return [Symbol, OpenAI::Models::ContainerCreateParams::ExpiresAfter::Anchor]
  37. 1 required :anchor, enum: -> { OpenAI::ContainerCreateParams::ExpiresAfter::Anchor }
  38. # @!attribute minutes
  39. #
  40. # @return [Integer]
  41. 1 required :minutes, Integer
  42. # @!method initialize(anchor:, minutes:)
  43. # Some parameter documentations has been truncated, see
  44. # {OpenAI::Models::ContainerCreateParams::ExpiresAfter} for more details.
  45. #
  46. # Container expiration time in seconds relative to the 'anchor' time.
  47. #
  48. # @param anchor [Symbol, OpenAI::Models::ContainerCreateParams::ExpiresAfter::Anchor] Time anchor for the expiration time. Currently only 'last_active_at' is supporte
  49. #
  50. # @param minutes [Integer]
  51. # Time anchor for the expiration time. Currently only 'last_active_at' is
  52. # supported.
  53. #
  54. # @see OpenAI::Models::ContainerCreateParams::ExpiresAfter#anchor
  55. 1 module Anchor
  56. 1 extend OpenAI::Internal::Type::Enum
  57. 1 LAST_ACTIVE_AT = :last_active_at
  58. # @!method self.values
  59. # @return [Array<Symbol>]
  60. end
  61. end
  62. end
  63. end
  64. end

openai-ruby/lib/openai/models/container_create_response.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Containers#create
  5. 1 class ContainerCreateResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # Unique identifier for the container.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # Unix timestamp (in seconds) when the container was created.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute name
  17. # Name of the container.
  18. #
  19. # @return [String]
  20. 1 required :name, String
  21. # @!attribute object
  22. # The type of this object.
  23. #
  24. # @return [String]
  25. 1 required :object, String
  26. # @!attribute status
  27. # Status of the container (e.g., active, deleted).
  28. #
  29. # @return [String]
  30. 1 required :status, String
  31. # @!attribute expires_after
  32. # The container will expire after this time period. The anchor is the reference
  33. # point for the expiration. The minutes is the number of minutes after the anchor
  34. # before the container expires.
  35. #
  36. # @return [OpenAI::Models::ContainerCreateResponse::ExpiresAfter, nil]
  37. 1 optional :expires_after, -> { OpenAI::Models::ContainerCreateResponse::ExpiresAfter }
  38. # @!method initialize(id:, created_at:, name:, object:, status:, expires_after: nil)
  39. # Some parameter documentations has been truncated, see
  40. # {OpenAI::Models::ContainerCreateResponse} for more details.
  41. #
  42. # @param id [String] Unique identifier for the container.
  43. #
  44. # @param created_at [Integer] Unix timestamp (in seconds) when the container was created.
  45. #
  46. # @param name [String] Name of the container.
  47. #
  48. # @param object [String] The type of this object.
  49. #
  50. # @param status [String] Status of the container (e.g., active, deleted).
  51. #
  52. # @param expires_after [OpenAI::Models::ContainerCreateResponse::ExpiresAfter] The container will expire after this time period.
  53. # @see OpenAI::Models::ContainerCreateResponse#expires_after
  54. 1 class ExpiresAfter < OpenAI::Internal::Type::BaseModel
  55. # @!attribute anchor
  56. # The reference point for the expiration.
  57. #
  58. # @return [Symbol, OpenAI::Models::ContainerCreateResponse::ExpiresAfter::Anchor, nil]
  59. 1 optional :anchor, enum: -> { OpenAI::Models::ContainerCreateResponse::ExpiresAfter::Anchor }
  60. # @!attribute minutes
  61. # The number of minutes after the anchor before the container expires.
  62. #
  63. # @return [Integer, nil]
  64. 1 optional :minutes, Integer
  65. # @!method initialize(anchor: nil, minutes: nil)
  66. # The container will expire after this time period. The anchor is the reference
  67. # point for the expiration. The minutes is the number of minutes after the anchor
  68. # before the container expires.
  69. #
  70. # @param anchor [Symbol, OpenAI::Models::ContainerCreateResponse::ExpiresAfter::Anchor] The reference point for the expiration.
  71. #
  72. # @param minutes [Integer] The number of minutes after the anchor before the container expires.
  73. # The reference point for the expiration.
  74. #
  75. # @see OpenAI::Models::ContainerCreateResponse::ExpiresAfter#anchor
  76. 1 module Anchor
  77. 1 extend OpenAI::Internal::Type::Enum
  78. 1 LAST_ACTIVE_AT = :last_active_at
  79. # @!method self.values
  80. # @return [Array<Symbol>]
  81. end
  82. end
  83. end
  84. end
  85. end

openai-ruby/lib/openai/models/container_delete_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Containers#delete
  5. 1 class ContainerDeleteParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/container_list_params.rb

100.0% lines covered

100.0% branches covered

12 relevant lines. 12 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Containers#list
  5. 1 class ContainerListParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute after
  9. # A cursor for use in pagination. `after` is an object ID that defines your place
  10. # in the list. For instance, if you make a list request and receive 100 objects,
  11. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  12. # fetch the next page of the list.
  13. #
  14. # @return [String, nil]
  15. 1 optional :after, String
  16. # @!attribute limit
  17. # A limit on the number of objects to be returned. Limit can range between 1 and
  18. # 100, and the default is 20.
  19. #
  20. # @return [Integer, nil]
  21. 1 optional :limit, Integer
  22. # @!attribute order
  23. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  24. # order and `desc` for descending order.
  25. #
  26. # @return [Symbol, OpenAI::Models::ContainerListParams::Order, nil]
  27. 1 optional :order, enum: -> { OpenAI::ContainerListParams::Order }
  28. # @!method initialize(after: nil, limit: nil, order: nil, request_options: {})
  29. # Some parameter documentations has been truncated, see
  30. # {OpenAI::Models::ContainerListParams} for more details.
  31. #
  32. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  33. #
  34. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  35. #
  36. # @param order [Symbol, OpenAI::Models::ContainerListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  37. #
  38. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  39. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  40. # order and `desc` for descending order.
  41. 1 module Order
  42. 1 extend OpenAI::Internal::Type::Enum
  43. 1 ASC = :asc
  44. 1 DESC = :desc
  45. # @!method self.values
  46. # @return [Array<Symbol>]
  47. end
  48. end
  49. end
  50. end

openai-ruby/lib/openai/models/container_list_response.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Containers#list
  5. 1 class ContainerListResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # Unique identifier for the container.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # Unix timestamp (in seconds) when the container was created.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute name
  17. # Name of the container.
  18. #
  19. # @return [String]
  20. 1 required :name, String
  21. # @!attribute object
  22. # The type of this object.
  23. #
  24. # @return [String]
  25. 1 required :object, String
  26. # @!attribute status
  27. # Status of the container (e.g., active, deleted).
  28. #
  29. # @return [String]
  30. 1 required :status, String
  31. # @!attribute expires_after
  32. # The container will expire after this time period. The anchor is the reference
  33. # point for the expiration. The minutes is the number of minutes after the anchor
  34. # before the container expires.
  35. #
  36. # @return [OpenAI::Models::ContainerListResponse::ExpiresAfter, nil]
  37. 1 optional :expires_after, -> { OpenAI::Models::ContainerListResponse::ExpiresAfter }
  38. # @!method initialize(id:, created_at:, name:, object:, status:, expires_after: nil)
  39. # Some parameter documentations has been truncated, see
  40. # {OpenAI::Models::ContainerListResponse} for more details.
  41. #
  42. # @param id [String] Unique identifier for the container.
  43. #
  44. # @param created_at [Integer] Unix timestamp (in seconds) when the container was created.
  45. #
  46. # @param name [String] Name of the container.
  47. #
  48. # @param object [String] The type of this object.
  49. #
  50. # @param status [String] Status of the container (e.g., active, deleted).
  51. #
  52. # @param expires_after [OpenAI::Models::ContainerListResponse::ExpiresAfter] The container will expire after this time period.
  53. # @see OpenAI::Models::ContainerListResponse#expires_after
  54. 1 class ExpiresAfter < OpenAI::Internal::Type::BaseModel
  55. # @!attribute anchor
  56. # The reference point for the expiration.
  57. #
  58. # @return [Symbol, OpenAI::Models::ContainerListResponse::ExpiresAfter::Anchor, nil]
  59. 1 optional :anchor, enum: -> { OpenAI::Models::ContainerListResponse::ExpiresAfter::Anchor }
  60. # @!attribute minutes
  61. # The number of minutes after the anchor before the container expires.
  62. #
  63. # @return [Integer, nil]
  64. 1 optional :minutes, Integer
  65. # @!method initialize(anchor: nil, minutes: nil)
  66. # The container will expire after this time period. The anchor is the reference
  67. # point for the expiration. The minutes is the number of minutes after the anchor
  68. # before the container expires.
  69. #
  70. # @param anchor [Symbol, OpenAI::Models::ContainerListResponse::ExpiresAfter::Anchor] The reference point for the expiration.
  71. #
  72. # @param minutes [Integer] The number of minutes after the anchor before the container expires.
  73. # The reference point for the expiration.
  74. #
  75. # @see OpenAI::Models::ContainerListResponse::ExpiresAfter#anchor
  76. 1 module Anchor
  77. 1 extend OpenAI::Internal::Type::Enum
  78. 1 LAST_ACTIVE_AT = :last_active_at
  79. # @!method self.values
  80. # @return [Array<Symbol>]
  81. end
  82. end
  83. end
  84. end
  85. end

openai-ruby/lib/openai/models/container_retrieve_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Containers#retrieve
  5. 1 class ContainerRetrieveParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/container_retrieve_response.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Containers#retrieve
  5. 1 class ContainerRetrieveResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # Unique identifier for the container.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # Unix timestamp (in seconds) when the container was created.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute name
  17. # Name of the container.
  18. #
  19. # @return [String]
  20. 1 required :name, String
  21. # @!attribute object
  22. # The type of this object.
  23. #
  24. # @return [String]
  25. 1 required :object, String
  26. # @!attribute status
  27. # Status of the container (e.g., active, deleted).
  28. #
  29. # @return [String]
  30. 1 required :status, String
  31. # @!attribute expires_after
  32. # The container will expire after this time period. The anchor is the reference
  33. # point for the expiration. The minutes is the number of minutes after the anchor
  34. # before the container expires.
  35. #
  36. # @return [OpenAI::Models::ContainerRetrieveResponse::ExpiresAfter, nil]
  37. 1 optional :expires_after, -> { OpenAI::Models::ContainerRetrieveResponse::ExpiresAfter }
  38. # @!method initialize(id:, created_at:, name:, object:, status:, expires_after: nil)
  39. # Some parameter documentations has been truncated, see
  40. # {OpenAI::Models::ContainerRetrieveResponse} for more details.
  41. #
  42. # @param id [String] Unique identifier for the container.
  43. #
  44. # @param created_at [Integer] Unix timestamp (in seconds) when the container was created.
  45. #
  46. # @param name [String] Name of the container.
  47. #
  48. # @param object [String] The type of this object.
  49. #
  50. # @param status [String] Status of the container (e.g., active, deleted).
  51. #
  52. # @param expires_after [OpenAI::Models::ContainerRetrieveResponse::ExpiresAfter] The container will expire after this time period.
  53. # @see OpenAI::Models::ContainerRetrieveResponse#expires_after
  54. 1 class ExpiresAfter < OpenAI::Internal::Type::BaseModel
  55. # @!attribute anchor
  56. # The reference point for the expiration.
  57. #
  58. # @return [Symbol, OpenAI::Models::ContainerRetrieveResponse::ExpiresAfter::Anchor, nil]
  59. 1 optional :anchor, enum: -> { OpenAI::Models::ContainerRetrieveResponse::ExpiresAfter::Anchor }
  60. # @!attribute minutes
  61. # The number of minutes after the anchor before the container expires.
  62. #
  63. # @return [Integer, nil]
  64. 1 optional :minutes, Integer
  65. # @!method initialize(anchor: nil, minutes: nil)
  66. # The container will expire after this time period. The anchor is the reference
  67. # point for the expiration. The minutes is the number of minutes after the anchor
  68. # before the container expires.
  69. #
  70. # @param anchor [Symbol, OpenAI::Models::ContainerRetrieveResponse::ExpiresAfter::Anchor] The reference point for the expiration.
  71. #
  72. # @param minutes [Integer] The number of minutes after the anchor before the container expires.
  73. # The reference point for the expiration.
  74. #
  75. # @see OpenAI::Models::ContainerRetrieveResponse::ExpiresAfter#anchor
  76. 1 module Anchor
  77. 1 extend OpenAI::Internal::Type::Enum
  78. 1 LAST_ACTIVE_AT = :last_active_at
  79. # @!method self.values
  80. # @return [Array<Symbol>]
  81. end
  82. end
  83. end
  84. end
  85. end

openai-ruby/lib/openai/models/containers/file_create_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Containers
  5. # @see OpenAI::Resources::Containers::Files#create
  6. 1 class FileCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute file
  10. # The File object (not file name) to be uploaded.
  11. #
  12. # @return [Pathname, StringIO, IO, String, OpenAI::FilePart, nil]
  13. 1 optional :file, OpenAI::Internal::Type::FileInput
  14. # @!attribute file_id
  15. # Name of the file to create.
  16. #
  17. # @return [String, nil]
  18. 1 optional :file_id, String
  19. # @!method initialize(file: nil, file_id: nil, request_options: {})
  20. # Some parameter documentations has been truncated, see
  21. # {OpenAI::Models::Containers::FileCreateParams} for more details.
  22. #
  23. # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The File object (not file name) to be uploaded.
  24. #
  25. # @param file_id [String] Name of the file to create.
  26. #
  27. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  28. end
  29. end
  30. end
  31. end

openai-ruby/lib/openai/models/containers/file_create_response.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Containers
  5. # @see OpenAI::Resources::Containers::Files#create
  6. 1 class FileCreateResponse < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # Unique identifier for the file.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute bytes
  13. # Size of the file in bytes.
  14. #
  15. # @return [Integer]
  16. 1 required :bytes, Integer
  17. # @!attribute container_id
  18. # The container this file belongs to.
  19. #
  20. # @return [String]
  21. 1 required :container_id, String
  22. # @!attribute created_at
  23. # Unix timestamp (in seconds) when the file was created.
  24. #
  25. # @return [Integer]
  26. 1 required :created_at, Integer
  27. # @!attribute object
  28. # The type of this object (`container.file`).
  29. #
  30. # @return [Symbol, :"container.file"]
  31. 1 required :object, const: :"container.file"
  32. # @!attribute path
  33. # Path of the file in the container.
  34. #
  35. # @return [String]
  36. 1 required :path, String
  37. # @!attribute source
  38. # Source of the file (e.g., `user`, `assistant`).
  39. #
  40. # @return [String]
  41. 1 required :source, String
  42. # @!method initialize(id:, bytes:, container_id:, created_at:, path:, source:, object: :"container.file")
  43. # @param id [String] Unique identifier for the file.
  44. #
  45. # @param bytes [Integer] Size of the file in bytes.
  46. #
  47. # @param container_id [String] The container this file belongs to.
  48. #
  49. # @param created_at [Integer] Unix timestamp (in seconds) when the file was created.
  50. #
  51. # @param path [String] Path of the file in the container.
  52. #
  53. # @param source [String] Source of the file (e.g., `user`, `assistant`).
  54. #
  55. # @param object [Symbol, :"container.file"] The type of this object (`container.file`).
  56. end
  57. end
  58. end
  59. end

openai-ruby/lib/openai/models/containers/file_delete_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Containers
  5. # @see OpenAI::Resources::Containers::Files#delete
  6. 1 class FileDeleteParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute container_id
  10. #
  11. # @return [String]
  12. 1 required :container_id, String
  13. # @!method initialize(container_id:, request_options: {})
  14. # @param container_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/containers/file_list_params.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Containers
  5. # @see OpenAI::Resources::Containers::Files#list
  6. 1 class FileListParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute after
  10. # A cursor for use in pagination. `after` is an object ID that defines your place
  11. # in the list. For instance, if you make a list request and receive 100 objects,
  12. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  13. # fetch the next page of the list.
  14. #
  15. # @return [String, nil]
  16. 1 optional :after, String
  17. # @!attribute limit
  18. # A limit on the number of objects to be returned. Limit can range between 1 and
  19. # 100, and the default is 20.
  20. #
  21. # @return [Integer, nil]
  22. 1 optional :limit, Integer
  23. # @!attribute order
  24. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  25. # order and `desc` for descending order.
  26. #
  27. # @return [Symbol, OpenAI::Models::Containers::FileListParams::Order, nil]
  28. 1 optional :order, enum: -> { OpenAI::Containers::FileListParams::Order }
  29. # @!method initialize(after: nil, limit: nil, order: nil, request_options: {})
  30. # Some parameter documentations has been truncated, see
  31. # {OpenAI::Models::Containers::FileListParams} for more details.
  32. #
  33. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  34. #
  35. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  36. #
  37. # @param order [Symbol, OpenAI::Models::Containers::FileListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  38. #
  39. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  40. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  41. # order and `desc` for descending order.
  42. 1 module Order
  43. 1 extend OpenAI::Internal::Type::Enum
  44. 1 ASC = :asc
  45. 1 DESC = :desc
  46. # @!method self.values
  47. # @return [Array<Symbol>]
  48. end
  49. end
  50. end
  51. end
  52. end

openai-ruby/lib/openai/models/containers/file_list_response.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Containers
  5. # @see OpenAI::Resources::Containers::Files#list
  6. 1 class FileListResponse < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # Unique identifier for the file.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute bytes
  13. # Size of the file in bytes.
  14. #
  15. # @return [Integer]
  16. 1 required :bytes, Integer
  17. # @!attribute container_id
  18. # The container this file belongs to.
  19. #
  20. # @return [String]
  21. 1 required :container_id, String
  22. # @!attribute created_at
  23. # Unix timestamp (in seconds) when the file was created.
  24. #
  25. # @return [Integer]
  26. 1 required :created_at, Integer
  27. # @!attribute object
  28. # The type of this object (`container.file`).
  29. #
  30. # @return [Symbol, :"container.file"]
  31. 1 required :object, const: :"container.file"
  32. # @!attribute path
  33. # Path of the file in the container.
  34. #
  35. # @return [String]
  36. 1 required :path, String
  37. # @!attribute source
  38. # Source of the file (e.g., `user`, `assistant`).
  39. #
  40. # @return [String]
  41. 1 required :source, String
  42. # @!method initialize(id:, bytes:, container_id:, created_at:, path:, source:, object: :"container.file")
  43. # @param id [String] Unique identifier for the file.
  44. #
  45. # @param bytes [Integer] Size of the file in bytes.
  46. #
  47. # @param container_id [String] The container this file belongs to.
  48. #
  49. # @param created_at [Integer] Unix timestamp (in seconds) when the file was created.
  50. #
  51. # @param path [String] Path of the file in the container.
  52. #
  53. # @param source [String] Source of the file (e.g., `user`, `assistant`).
  54. #
  55. # @param object [Symbol, :"container.file"] The type of this object (`container.file`).
  56. end
  57. end
  58. end
  59. end

openai-ruby/lib/openai/models/containers/file_retrieve_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Containers
  5. # @see OpenAI::Resources::Containers::Files#retrieve
  6. 1 class FileRetrieveParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute container_id
  10. #
  11. # @return [String]
  12. 1 required :container_id, String
  13. # @!method initialize(container_id:, request_options: {})
  14. # @param container_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/containers/file_retrieve_response.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Containers
  5. # @see OpenAI::Resources::Containers::Files#retrieve
  6. 1 class FileRetrieveResponse < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # Unique identifier for the file.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute bytes
  13. # Size of the file in bytes.
  14. #
  15. # @return [Integer]
  16. 1 required :bytes, Integer
  17. # @!attribute container_id
  18. # The container this file belongs to.
  19. #
  20. # @return [String]
  21. 1 required :container_id, String
  22. # @!attribute created_at
  23. # Unix timestamp (in seconds) when the file was created.
  24. #
  25. # @return [Integer]
  26. 1 required :created_at, Integer
  27. # @!attribute object
  28. # The type of this object (`container.file`).
  29. #
  30. # @return [Symbol, :"container.file"]
  31. 1 required :object, const: :"container.file"
  32. # @!attribute path
  33. # Path of the file in the container.
  34. #
  35. # @return [String]
  36. 1 required :path, String
  37. # @!attribute source
  38. # Source of the file (e.g., `user`, `assistant`).
  39. #
  40. # @return [String]
  41. 1 required :source, String
  42. # @!method initialize(id:, bytes:, container_id:, created_at:, path:, source:, object: :"container.file")
  43. # @param id [String] Unique identifier for the file.
  44. #
  45. # @param bytes [Integer] Size of the file in bytes.
  46. #
  47. # @param container_id [String] The container this file belongs to.
  48. #
  49. # @param created_at [Integer] Unix timestamp (in seconds) when the file was created.
  50. #
  51. # @param path [String] Path of the file in the container.
  52. #
  53. # @param source [String] Source of the file (e.g., `user`, `assistant`).
  54. #
  55. # @param object [Symbol, :"container.file"] The type of this object (`container.file`).
  56. end
  57. end
  58. end
  59. end

openai-ruby/lib/openai/models/containers/files/content_retrieve_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Containers
  5. 1 module Files
  6. # @see OpenAI::Resources::Containers::Files::Content#retrieve
  7. 1 class ContentRetrieveParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute container_id
  11. #
  12. # @return [String]
  13. 1 required :container_id, String
  14. # @!method initialize(container_id:, request_options: {})
  15. # @param container_id [String]
  16. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  17. end
  18. end
  19. end
  20. end
  21. end

openai-ruby/lib/openai/models/create_embedding_response.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Embeddings#create
  5. 1 class CreateEmbeddingResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute data
  7. # The list of embeddings generated by the model.
  8. #
  9. # @return [Array<OpenAI::Models::Embedding>]
  10. 1 required :data, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Embedding] }
  11. # @!attribute model
  12. # The name of the model used to generate the embedding.
  13. #
  14. # @return [String]
  15. 1 required :model, String
  16. # @!attribute object
  17. # The object type, which is always "list".
  18. #
  19. # @return [Symbol, :list]
  20. 1 required :object, const: :list
  21. # @!attribute usage
  22. # The usage information for the request.
  23. #
  24. # @return [OpenAI::Models::CreateEmbeddingResponse::Usage]
  25. 1 required :usage, -> { OpenAI::CreateEmbeddingResponse::Usage }
  26. # @!method initialize(data:, model:, usage:, object: :list)
  27. # @param data [Array<OpenAI::Models::Embedding>] The list of embeddings generated by the model.
  28. #
  29. # @param model [String] The name of the model used to generate the embedding.
  30. #
  31. # @param usage [OpenAI::Models::CreateEmbeddingResponse::Usage] The usage information for the request.
  32. #
  33. # @param object [Symbol, :list] The object type, which is always "list".
  34. # @see OpenAI::Models::CreateEmbeddingResponse#usage
  35. 1 class Usage < OpenAI::Internal::Type::BaseModel
  36. # @!attribute prompt_tokens
  37. # The number of tokens used by the prompt.
  38. #
  39. # @return [Integer]
  40. 1 required :prompt_tokens, Integer
  41. # @!attribute total_tokens
  42. # The total number of tokens used by the request.
  43. #
  44. # @return [Integer]
  45. 1 required :total_tokens, Integer
  46. # @!method initialize(prompt_tokens:, total_tokens:)
  47. # The usage information for the request.
  48. #
  49. # @param prompt_tokens [Integer] The number of tokens used by the prompt.
  50. #
  51. # @param total_tokens [Integer] The total number of tokens used by the request.
  52. end
  53. end
  54. end
  55. end

openai-ruby/lib/openai/models/embedding.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class Embedding < OpenAI::Internal::Type::BaseModel
  5. # @!attribute embedding
  6. # The embedding vector, which is a list of floats. The length of vector depends on
  7. # the model as listed in the
  8. # [embedding guide](https://platform.openai.com/docs/guides/embeddings).
  9. #
  10. # @return [Array<Float>]
  11. 1 required :embedding, OpenAI::Internal::Type::ArrayOf[Float]
  12. # @!attribute index
  13. # The index of the embedding in the list of embeddings.
  14. #
  15. # @return [Integer]
  16. 1 required :index, Integer
  17. # @!attribute object
  18. # The object type, which is always "embedding".
  19. #
  20. # @return [Symbol, :embedding]
  21. 1 required :object, const: :embedding
  22. # @!method initialize(embedding:, index:, object: :embedding)
  23. # Some parameter documentations has been truncated, see
  24. # {OpenAI::Models::Embedding} for more details.
  25. #
  26. # Represents an embedding vector returned by embedding endpoint.
  27. #
  28. # @param embedding [Array<Float>] The embedding vector, which is a list of floats. The length of vector depends on
  29. #
  30. # @param index [Integer] The index of the embedding in the list of embeddings.
  31. #
  32. # @param object [Symbol, :embedding] The object type, which is always "embedding".
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/embedding_create_params.rb

100.0% lines covered

100.0% branches covered

27 relevant lines. 27 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Embeddings#create
  5. 1 class EmbeddingCreateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute input
  9. # Input text to embed, encoded as a string or array of tokens. To embed multiple
  10. # inputs in a single request, pass an array of strings or array of token arrays.
  11. # The input must not exceed the max input tokens for the model (8192 tokens for
  12. # all embedding models), cannot be an empty string, and any array must be 2048
  13. # dimensions or less.
  14. # [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
  15. # for counting tokens. In addition to the per-input token limit, all embedding
  16. # models enforce a maximum of 300,000 tokens summed across all inputs in a single
  17. # request.
  18. #
  19. # @return [String, Array<String>, Array<Integer>, Array<Array<Integer>>]
  20. 1 required :input, union: -> { OpenAI::EmbeddingCreateParams::Input }
  21. # @!attribute model
  22. # ID of the model to use. You can use the
  23. # [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  24. # see all of your available models, or see our
  25. # [Model overview](https://platform.openai.com/docs/models) for descriptions of
  26. # them.
  27. #
  28. # @return [String, Symbol, OpenAI::Models::EmbeddingModel]
  29. 1 required :model, union: -> { OpenAI::EmbeddingCreateParams::Model }
  30. # @!attribute dimensions
  31. # The number of dimensions the resulting output embeddings should have. Only
  32. # supported in `text-embedding-3` and later models.
  33. #
  34. # @return [Integer, nil]
  35. 1 optional :dimensions, Integer
  36. # @!attribute encoding_format
  37. # The format to return the embeddings in. Can be either `float` or
  38. # [`base64`](https://pypi.org/project/pybase64/).
  39. #
  40. # @return [Symbol, OpenAI::Models::EmbeddingCreateParams::EncodingFormat, nil]
  41. 1 optional :encoding_format, enum: -> { OpenAI::EmbeddingCreateParams::EncodingFormat }
  42. # @!attribute user
  43. # A unique identifier representing your end-user, which can help OpenAI to monitor
  44. # and detect abuse.
  45. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
  46. #
  47. # @return [String, nil]
  48. 1 optional :user, String
  49. # @!method initialize(input:, model:, dimensions: nil, encoding_format: nil, user: nil, request_options: {})
  50. # Some parameter documentations has been truncated, see
  51. # {OpenAI::Models::EmbeddingCreateParams} for more details.
  52. #
  53. # @param input [String, Array<String>, Array<Integer>, Array<Array<Integer>>] Input text to embed, encoded as a string or array of tokens. To embed multiple i
  54. #
  55. # @param model [String, Symbol, OpenAI::Models::EmbeddingModel] ID of the model to use. You can use the [List models](https://platform.openai.co
  56. #
  57. # @param dimensions [Integer] The number of dimensions the resulting output embeddings should have. Only suppo
  58. #
  59. # @param encoding_format [Symbol, OpenAI::Models::EmbeddingCreateParams::EncodingFormat] The format to return the embeddings in. Can be either `float` or [`base64`](http
  60. #
  61. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  62. #
  63. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  64. # Input text to embed, encoded as a string or array of tokens. To embed multiple
  65. # inputs in a single request, pass an array of strings or array of token arrays.
  66. # The input must not exceed the max input tokens for the model (8192 tokens for
  67. # all embedding models), cannot be an empty string, and any array must be 2048
  68. # dimensions or less.
  69. # [Example Python code](https://cookbook.openai.com/examples/how_to_count_tokens_with_tiktoken)
  70. # for counting tokens. In addition to the per-input token limit, all embedding
  71. # models enforce a maximum of 300,000 tokens summed across all inputs in a single
  72. # request.
  73. 1 module Input
  74. 1 extend OpenAI::Internal::Type::Union
  75. # The string that will be turned into an embedding.
  76. 1 variant String
  77. # The array of strings that will be turned into an embedding.
  78. 1 variant -> { OpenAI::Models::EmbeddingCreateParams::Input::StringArray }
  79. # The array of integers that will be turned into an embedding.
  80. 1 variant -> { OpenAI::Models::EmbeddingCreateParams::Input::IntegerArray }
  81. # The array of arrays containing integers that will be turned into an embedding.
  82. 1 variant -> { OpenAI::Models::EmbeddingCreateParams::Input::ArrayOfToken2DArray }
  83. # @!method self.variants
  84. # @return [Array(String, Array<String>, Array<Integer>, Array<Array<Integer>>)]
  85. # @type [OpenAI::Internal::Type::Converter]
  86. 1 StringArray = OpenAI::Internal::Type::ArrayOf[String]
  87. # @type [OpenAI::Internal::Type::Converter]
  88. 1 IntegerArray = OpenAI::Internal::Type::ArrayOf[Integer]
  89. # @type [OpenAI::Internal::Type::Converter]
  90. 1 ArrayOfToken2DArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::ArrayOf[Integer]]
  91. end
  92. # ID of the model to use. You can use the
  93. # [List models](https://platform.openai.com/docs/api-reference/models/list) API to
  94. # see all of your available models, or see our
  95. # [Model overview](https://platform.openai.com/docs/models) for descriptions of
  96. # them.
  97. 1 module Model
  98. 1 extend OpenAI::Internal::Type::Union
  99. 1 variant String
  100. # ID of the model to use. You can use the [List models](https://platform.openai.com/docs/api-reference/models/list) API to see all of your available models, or see our [Model overview](https://platform.openai.com/docs/models) for descriptions of them.
  101. 1 variant enum: -> { OpenAI::EmbeddingModel }
  102. # @!method self.variants
  103. # @return [Array(String, Symbol, OpenAI::Models::EmbeddingModel)]
  104. end
  105. # The format to return the embeddings in. Can be either `float` or
  106. # [`base64`](https://pypi.org/project/pybase64/).
  107. 1 module EncodingFormat
  108. 1 extend OpenAI::Internal::Type::Enum
  109. 1 FLOAT = :float
  110. 1 BASE64 = :base64
  111. # @!method self.values
  112. # @return [Array<Symbol>]
  113. end
  114. end
  115. end
  116. end

openai-ruby/lib/openai/models/embedding_model.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module EmbeddingModel
  5. 1 extend OpenAI::Internal::Type::Enum
  6. 1 TEXT_EMBEDDING_ADA_002 = :"text-embedding-ada-002"
  7. 1 TEXT_EMBEDDING_3_SMALL = :"text-embedding-3-small"
  8. 1 TEXT_EMBEDDING_3_LARGE = :"text-embedding-3-large"
  9. # @!method self.values
  10. # @return [Array<Symbol>]
  11. end
  12. end
  13. end

openai-ruby/lib/openai/models/error_object.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ErrorObject < OpenAI::Internal::Type::BaseModel
  5. # @!attribute code
  6. #
  7. # @return [String, nil]
  8. 1 required :code, String, nil?: true
  9. # @!attribute message
  10. #
  11. # @return [String]
  12. 1 required :message, String
  13. # @!attribute param
  14. #
  15. # @return [String, nil]
  16. 1 required :param, String, nil?: true
  17. # @!attribute type
  18. #
  19. # @return [String]
  20. 1 required :type, String
  21. # @!method initialize(code:, message:, param:, type:)
  22. # @param code [String, nil]
  23. # @param message [String]
  24. # @param param [String, nil]
  25. # @param type [String]
  26. end
  27. end
  28. end

openai-ruby/lib/openai/models/eval_create_params.rb

92.05% lines covered

100.0% branches covered

88 relevant lines. 81 lines covered and 7 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#create
  5. 1 class EvalCreateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute data_source_config
  9. # The configuration for the data source used for the evaluation runs. Dictates the
  10. # schema of the data used in the evaluation.
  11. #
  12. # @return [OpenAI::Models::EvalCreateParams::DataSourceConfig::Custom, OpenAI::Models::EvalCreateParams::DataSourceConfig::Logs, OpenAI::Models::EvalCreateParams::DataSourceConfig::StoredCompletions]
  13. 1 required :data_source_config, union: -> { OpenAI::EvalCreateParams::DataSourceConfig }
  14. # @!attribute testing_criteria
  15. # A list of graders for all eval runs in this group. Graders can reference
  16. # variables in the data source using double curly braces notation, like
  17. # `{{item.variable_name}}`. To reference the model's output, use the `sample`
  18. # namespace (ie, `{{sample.output_text}}`).
  19. #
  20. # @return [Array<OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalCreateParams::TestingCriterion::TextSimilarity, OpenAI::Models::EvalCreateParams::TestingCriterion::Python, OpenAI::Models::EvalCreateParams::TestingCriterion::ScoreModel>]
  21. 1 required :testing_criteria,
  22. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::EvalCreateParams::TestingCriterion] }
  23. # @!attribute metadata
  24. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  25. # for storing additional information about the object in a structured format, and
  26. # querying for objects via API or the dashboard.
  27. #
  28. # Keys are strings with a maximum length of 64 characters. Values are strings with
  29. # a maximum length of 512 characters.
  30. #
  31. # @return [Hash{Symbol=>String}, nil]
  32. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  33. # @!attribute name
  34. # The name of the evaluation.
  35. #
  36. # @return [String, nil]
  37. 1 optional :name, String
  38. # @!method initialize(data_source_config:, testing_criteria:, metadata: nil, name: nil, request_options: {})
  39. # Some parameter documentations has been truncated, see
  40. # {OpenAI::Models::EvalCreateParams} for more details.
  41. #
  42. # @param data_source_config [OpenAI::Models::EvalCreateParams::DataSourceConfig::Custom, OpenAI::Models::EvalCreateParams::DataSourceConfig::Logs, OpenAI::Models::EvalCreateParams::DataSourceConfig::StoredCompletions] The configuration for the data source used for the evaluation runs. Dictates the
  43. #
  44. # @param testing_criteria [Array<OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalCreateParams::TestingCriterion::TextSimilarity, OpenAI::Models::EvalCreateParams::TestingCriterion::Python, OpenAI::Models::EvalCreateParams::TestingCriterion::ScoreModel>] A list of graders for all eval runs in this group. Graders can reference variabl
  45. #
  46. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  47. #
  48. # @param name [String] The name of the evaluation.
  49. #
  50. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  51. # The configuration for the data source used for the evaluation runs. Dictates the
  52. # schema of the data used in the evaluation.
  53. 1 module DataSourceConfig
  54. 1 extend OpenAI::Internal::Type::Union
  55. 1 discriminator :type
  56. # A CustomDataSourceConfig object that defines the schema for the data source used for the evaluation runs.
  57. # This schema is used to define the shape of the data that will be:
  58. # - Used to define your testing criteria and
  59. # - What data is required when creating a run
  60. 1 variant :custom, -> { OpenAI::EvalCreateParams::DataSourceConfig::Custom }
  61. # A data source config which specifies the metadata property of your logs query.
  62. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.
  63. 1 variant :logs, -> { OpenAI::EvalCreateParams::DataSourceConfig::Logs }
  64. # Deprecated in favor of LogsDataSourceConfig.
  65. 1 variant :stored_completions, -> { OpenAI::EvalCreateParams::DataSourceConfig::StoredCompletions }
  66. 1 class Custom < OpenAI::Internal::Type::BaseModel
  67. # @!attribute item_schema
  68. # The json schema for each row in the data source.
  69. #
  70. # @return [Hash{Symbol=>Object}]
  71. 1 required :item_schema, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  72. # @!attribute type
  73. # The type of data source. Always `custom`.
  74. #
  75. # @return [Symbol, :custom]
  76. 1 required :type, const: :custom
  77. # @!attribute include_sample_schema
  78. # Whether the eval should expect you to populate the sample namespace (ie, by
  79. # generating responses off of your data source)
  80. #
  81. # @return [Boolean, nil]
  82. 1 optional :include_sample_schema, OpenAI::Internal::Type::Boolean
  83. # @!method initialize(item_schema:, include_sample_schema: nil, type: :custom)
  84. # Some parameter documentations has been truncated, see
  85. # {OpenAI::Models::EvalCreateParams::DataSourceConfig::Custom} for more details.
  86. #
  87. # A CustomDataSourceConfig object that defines the schema for the data source used
  88. # for the evaluation runs. This schema is used to define the shape of the data
  89. # that will be:
  90. #
  91. # - Used to define your testing criteria and
  92. # - What data is required when creating a run
  93. #
  94. # @param item_schema [Hash{Symbol=>Object}] The json schema for each row in the data source.
  95. #
  96. # @param include_sample_schema [Boolean] Whether the eval should expect you to populate the sample namespace (ie, by gene
  97. #
  98. # @param type [Symbol, :custom] The type of data source. Always `custom`.
  99. end
  100. 1 class Logs < OpenAI::Internal::Type::BaseModel
  101. # @!attribute type
  102. # The type of data source. Always `logs`.
  103. #
  104. # @return [Symbol, :logs]
  105. 1 required :type, const: :logs
  106. # @!attribute metadata
  107. # Metadata filters for the logs data source.
  108. #
  109. # @return [Hash{Symbol=>Object}, nil]
  110. 1 optional :metadata, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  111. # @!method initialize(metadata: nil, type: :logs)
  112. # A data source config which specifies the metadata property of your logs query.
  113. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.
  114. #
  115. # @param metadata [Hash{Symbol=>Object}] Metadata filters for the logs data source.
  116. #
  117. # @param type [Symbol, :logs] The type of data source. Always `logs`.
  118. end
  119. # @deprecated
  120. 1 class StoredCompletions < OpenAI::Internal::Type::BaseModel
  121. # @!attribute type
  122. # The type of data source. Always `stored_completions`.
  123. #
  124. # @return [Symbol, :stored_completions]
  125. 1 required :type, const: :stored_completions
  126. # @!attribute metadata
  127. # Metadata filters for the stored completions data source.
  128. #
  129. # @return [Hash{Symbol=>Object}, nil]
  130. 1 optional :metadata, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  131. # @!method initialize(metadata: nil, type: :stored_completions)
  132. # Deprecated in favor of LogsDataSourceConfig.
  133. #
  134. # @param metadata [Hash{Symbol=>Object}] Metadata filters for the stored completions data source.
  135. #
  136. # @param type [Symbol, :stored_completions] The type of data source. Always `stored_completions`.
  137. end
  138. # @!method self.variants
  139. # @return [Array(OpenAI::Models::EvalCreateParams::DataSourceConfig::Custom, OpenAI::Models::EvalCreateParams::DataSourceConfig::Logs, OpenAI::Models::EvalCreateParams::DataSourceConfig::StoredCompletions)]
  140. end
  141. # A LabelModelGrader object which uses a model to assign labels to each item in
  142. # the evaluation.
  143. 1 module TestingCriterion
  144. 1 extend OpenAI::Internal::Type::Union
  145. 1 discriminator :type
  146. # A LabelModelGrader object which uses a model to assign labels to each item
  147. # in the evaluation.
  148. 1 variant :label_model, -> { OpenAI::EvalCreateParams::TestingCriterion::LabelModel }
  149. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  150. 1 variant :string_check, -> { OpenAI::Graders::StringCheckGrader }
  151. # A TextSimilarityGrader object which grades text based on similarity metrics.
  152. 1 variant :text_similarity, -> { OpenAI::EvalCreateParams::TestingCriterion::TextSimilarity }
  153. # A PythonGrader object that runs a python script on the input.
  154. 1 variant :python, -> { OpenAI::EvalCreateParams::TestingCriterion::Python }
  155. # A ScoreModelGrader object that uses a model to assign a score to the input.
  156. 1 variant :score_model, -> { OpenAI::EvalCreateParams::TestingCriterion::ScoreModel }
  157. 1 class LabelModel < OpenAI::Internal::Type::BaseModel
  158. # @!attribute input
  159. # A list of chat messages forming the prompt or context. May include variable
  160. # references to the `item` namespace, ie {{item.name}}.
  161. #
  162. # @return [Array<OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::SimpleInputMessage, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem>]
  163. 1 required :input,
  164. -> {
  165. OpenAI::Internal::Type::ArrayOf[union: OpenAI::EvalCreateParams::TestingCriterion::LabelModel::Input]
  166. }
  167. # @!attribute labels
  168. # The labels to classify to each item in the evaluation.
  169. #
  170. # @return [Array<String>]
  171. 1 required :labels, OpenAI::Internal::Type::ArrayOf[String]
  172. # @!attribute model
  173. # The model to use for the evaluation. Must support structured outputs.
  174. #
  175. # @return [String]
  176. 1 required :model, String
  177. # @!attribute name
  178. # The name of the grader.
  179. #
  180. # @return [String]
  181. 1 required :name, String
  182. # @!attribute passing_labels
  183. # The labels that indicate a passing result. Must be a subset of labels.
  184. #
  185. # @return [Array<String>]
  186. 1 required :passing_labels, OpenAI::Internal::Type::ArrayOf[String]
  187. # @!attribute type
  188. # The object type, which is always `label_model`.
  189. #
  190. # @return [Symbol, :label_model]
  191. 1 required :type, const: :label_model
  192. # @!method initialize(input:, labels:, model:, name:, passing_labels:, type: :label_model)
  193. # Some parameter documentations has been truncated, see
  194. # {OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel} for more
  195. # details.
  196. #
  197. # A LabelModelGrader object which uses a model to assign labels to each item in
  198. # the evaluation.
  199. #
  200. # @param input [Array<OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::SimpleInputMessage, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem>] A list of chat messages forming the prompt or context. May include variable refe
  201. #
  202. # @param labels [Array<String>] The labels to classify to each item in the evaluation.
  203. #
  204. # @param model [String] The model to use for the evaluation. Must support structured outputs.
  205. #
  206. # @param name [String] The name of the grader.
  207. #
  208. # @param passing_labels [Array<String>] The labels that indicate a passing result. Must be a subset of labels.
  209. #
  210. # @param type [Symbol, :label_model] The object type, which is always `label_model`.
  211. # A chat message that makes up the prompt or context. May include variable
  212. # references to the `item` namespace, ie {{item.name}}.
  213. 1 module Input
  214. 1 extend OpenAI::Internal::Type::Union
  215. 1 variant -> { OpenAI::EvalCreateParams::TestingCriterion::LabelModel::Input::SimpleInputMessage }
  216. # A message input to the model with a role indicating instruction following
  217. # hierarchy. Instructions given with the `developer` or `system` role take
  218. # precedence over instructions given with the `user` role. Messages with the
  219. # `assistant` role are presumed to have been generated by the model in previous
  220. # interactions.
  221. 1 variant -> { OpenAI::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem }
  222. 1 class SimpleInputMessage < OpenAI::Internal::Type::BaseModel
  223. # @!attribute content
  224. # The content of the message.
  225. #
  226. # @return [String]
  227. 1 required :content, String
  228. # @!attribute role
  229. # The role of the message (e.g. "system", "assistant", "user").
  230. #
  231. # @return [String]
  232. 1 required :role, String
  233. # @!method initialize(content:, role:)
  234. # @param content [String] The content of the message.
  235. #
  236. # @param role [String] The role of the message (e.g. "system", "assistant", "user").
  237. end
  238. 1 class EvalItem < OpenAI::Internal::Type::BaseModel
  239. # @!attribute content
  240. # Inputs to the model - can contain template strings.
  241. #
  242. # @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::OutputText, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::InputImage, Array<Object>]
  243. 1 required :content,
  244. union: -> {
  245. OpenAI::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content
  246. }
  247. # @!attribute role
  248. # The role of the message input. One of `user`, `assistant`, `system`, or
  249. # `developer`.
  250. #
  251. # @return [Symbol, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Role]
  252. 1 required :role,
  253. enum: -> {
  254. OpenAI::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Role
  255. }
  256. # @!attribute type
  257. # The type of the message input. Always `message`.
  258. #
  259. # @return [Symbol, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Type, nil]
  260. 1 optional :type,
  261. enum: -> {
  262. OpenAI::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Type
  263. }
  264. # @!method initialize(content:, role:, type: nil)
  265. # Some parameter documentations has been truncated, see
  266. # {OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem}
  267. # for more details.
  268. #
  269. # A message input to the model with a role indicating instruction following
  270. # hierarchy. Instructions given with the `developer` or `system` role take
  271. # precedence over instructions given with the `user` role. Messages with the
  272. # `assistant` role are presumed to have been generated by the model in previous
  273. # interactions.
  274. #
  275. # @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::OutputText, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::InputImage, Array<Object>] Inputs to the model - can contain template strings.
  276. #
  277. # @param role [Symbol, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  278. #
  279. # @param type [Symbol, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Type] The type of the message input. Always `message`.
  280. # Inputs to the model - can contain template strings.
  281. #
  282. # @see OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem#content
  283. 1 module Content
  284. 1 extend OpenAI::Internal::Type::Union
  285. # A text input to the model.
  286. 1 variant String
  287. # A text input to the model.
  288. 1 variant -> { OpenAI::Responses::ResponseInputText }
  289. # A text output from the model.
  290. 1 variant -> {
  291. OpenAI::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::OutputText
  292. }
  293. # An image input to the model.
  294. 1 variant -> {
  295. OpenAI::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::InputImage
  296. }
  297. # A list of inputs, each of which may be either an input text or input image object.
  298. 1 variant -> { OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::AnArrayOfInputTextAndInputImageArray }
  299. 1 class OutputText < OpenAI::Internal::Type::BaseModel
  300. # @!attribute text
  301. # The text output from the model.
  302. #
  303. # @return [String]
  304. 1 required :text, String
  305. # @!attribute type
  306. # The type of the output text. Always `output_text`.
  307. #
  308. # @return [Symbol, :output_text]
  309. 1 required :type, const: :output_text
  310. # @!method initialize(text:, type: :output_text)
  311. # Some parameter documentations has been truncated, see
  312. # {OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::OutputText}
  313. # for more details.
  314. #
  315. # A text output from the model.
  316. #
  317. # @param text [String] The text output from the model.
  318. #
  319. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  320. end
  321. 1 class InputImage < OpenAI::Internal::Type::BaseModel
  322. # @!attribute image_url
  323. # The URL of the image input.
  324. #
  325. # @return [String]
  326. 1 required :image_url, String
  327. # @!attribute type
  328. # The type of the image input. Always `input_image`.
  329. #
  330. # @return [Symbol, :input_image]
  331. 1 required :type, const: :input_image
  332. # @!attribute detail
  333. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  334. # `auto`. Defaults to `auto`.
  335. #
  336. # @return [String, nil]
  337. 1 optional :detail, String
  338. # @!method initialize(image_url:, detail: nil, type: :input_image)
  339. # Some parameter documentations has been truncated, see
  340. # {OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::InputImage}
  341. # for more details.
  342. #
  343. # An image input to the model.
  344. #
  345. # @param image_url [String] The URL of the image input.
  346. #
  347. # @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
  348. #
  349. # @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
  350. end
  351. # @!method self.variants
  352. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::OutputText, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem::Content::InputImage, Array<Object>)]
  353. # @type [OpenAI::Internal::Type::Converter]
  354. 1 AnArrayOfInputTextAndInputImageArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
  355. end
  356. # The role of the message input. One of `user`, `assistant`, `system`, or
  357. # `developer`.
  358. #
  359. # @see OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem#role
  360. 1 module Role
  361. 1 extend OpenAI::Internal::Type::Enum
  362. 1 USER = :user
  363. 1 ASSISTANT = :assistant
  364. 1 SYSTEM = :system
  365. 1 DEVELOPER = :developer
  366. # @!method self.values
  367. # @return [Array<Symbol>]
  368. end
  369. # The type of the message input. Always `message`.
  370. #
  371. # @see OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem#type
  372. 1 module Type
  373. 1 extend OpenAI::Internal::Type::Enum
  374. 1 MESSAGE = :message
  375. # @!method self.values
  376. # @return [Array<Symbol>]
  377. end
  378. end
  379. # @!method self.variants
  380. # @return [Array(OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::SimpleInputMessage, OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel::Input::EvalItem)]
  381. end
  382. end
  383. 1 class TextSimilarity < OpenAI::Models::Graders::TextSimilarityGrader
  384. # @!attribute pass_threshold
  385. # The threshold for the score.
  386. #
  387. # @return [Float]
  388. 1 required :pass_threshold, Float
  389. # @!method initialize(pass_threshold:)
  390. # A TextSimilarityGrader object which grades text based on similarity metrics.
  391. #
  392. # @param pass_threshold [Float] The threshold for the score.
  393. end
  394. 1 class Python < OpenAI::Models::Graders::PythonGrader
  395. # @!attribute pass_threshold
  396. # The threshold for the score.
  397. #
  398. # @return [Float, nil]
  399. 1 optional :pass_threshold, Float
  400. # @!method initialize(pass_threshold: nil)
  401. # A PythonGrader object that runs a python script on the input.
  402. #
  403. # @param pass_threshold [Float] The threshold for the score.
  404. end
  405. 1 class ScoreModel < OpenAI::Models::Graders::ScoreModelGrader
  406. # @!attribute pass_threshold
  407. # The threshold for the score.
  408. #
  409. # @return [Float, nil]
  410. 1 optional :pass_threshold, Float
  411. # @!method initialize(pass_threshold: nil)
  412. # A ScoreModelGrader object that uses a model to assign a score to the input.
  413. #
  414. # @param pass_threshold [Float] The threshold for the score.
  415. end
  416. # @!method self.variants
  417. # @return [Array(OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalCreateParams::TestingCriterion::TextSimilarity, OpenAI::Models::EvalCreateParams::TestingCriterion::Python, OpenAI::Models::EvalCreateParams::TestingCriterion::ScoreModel)]
  418. end
  419. end
  420. end
  421. end

openai-ruby/lib/openai/models/eval_create_response.rb

97.06% lines covered

100.0% branches covered

34 relevant lines. 33 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#create
  5. 1 class EvalCreateResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # Unique identifier for the evaluation.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) for when the eval was created.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data_source_config
  17. # Configuration of data sources used in runs of the evaluation.
  18. #
  19. # @return [OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalCreateResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig]
  20. 1 required :data_source_config, union: -> { OpenAI::Models::EvalCreateResponse::DataSourceConfig }
  21. # @!attribute metadata
  22. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  23. # for storing additional information about the object in a structured format, and
  24. # querying for objects via API or the dashboard.
  25. #
  26. # Keys are strings with a maximum length of 64 characters. Values are strings with
  27. # a maximum length of 512 characters.
  28. #
  29. # @return [Hash{Symbol=>String}, nil]
  30. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  31. # @!attribute name
  32. # The name of the evaluation.
  33. #
  34. # @return [String]
  35. 1 required :name, String
  36. # @!attribute object
  37. # The object type.
  38. #
  39. # @return [Symbol, :eval]
  40. 1 required :object, const: :eval
  41. # @!attribute testing_criteria
  42. # A list of testing criteria.
  43. #
  44. # @return [Array<OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderScoreModel>]
  45. 1 required :testing_criteria,
  46. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Models::EvalCreateResponse::TestingCriterion] }
  47. # @!method initialize(id:, created_at:, data_source_config:, metadata:, name:, testing_criteria:, object: :eval)
  48. # Some parameter documentations has been truncated, see
  49. # {OpenAI::Models::EvalCreateResponse} for more details.
  50. #
  51. # An Eval object with a data source config and testing criteria. An Eval
  52. # represents a task to be done for your LLM integration. Like:
  53. #
  54. # - Improve the quality of my chatbot
  55. # - See how well my chatbot handles customer support
  56. # - Check if o4-mini is better at my usecase than gpt-4o
  57. #
  58. # @param id [String] Unique identifier for the evaluation.
  59. #
  60. # @param created_at [Integer] The Unix timestamp (in seconds) for when the eval was created.
  61. #
  62. # @param data_source_config [OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalCreateResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig] Configuration of data sources used in runs of the evaluation.
  63. #
  64. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  65. #
  66. # @param name [String] The name of the evaluation.
  67. #
  68. # @param testing_criteria [Array<OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderScoreModel>] A list of testing criteria.
  69. #
  70. # @param object [Symbol, :eval] The object type.
  71. # Configuration of data sources used in runs of the evaluation.
  72. #
  73. # @see OpenAI::Models::EvalCreateResponse#data_source_config
  74. 1 module DataSourceConfig
  75. 1 extend OpenAI::Internal::Type::Union
  76. 1 discriminator :type
  77. # A CustomDataSourceConfig which specifies the schema of your `item` and optionally `sample` namespaces.
  78. # The response schema defines the shape of the data that will be:
  79. # - Used to define your testing criteria and
  80. # - What data is required when creating a run
  81. 1 variant :custom, -> { OpenAI::EvalCustomDataSourceConfig }
  82. # A LogsDataSourceConfig which specifies the metadata property of your logs query.
  83. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.
  84. # The schema returned by this data source config is used to defined what variables are available in your evals.
  85. # `item` and `sample` are both defined when using this data source config.
  86. 1 variant :logs, -> { OpenAI::Models::EvalCreateResponse::DataSourceConfig::Logs }
  87. # Deprecated in favor of LogsDataSourceConfig.
  88. 1 variant :stored_completions, -> { OpenAI::EvalStoredCompletionsDataSourceConfig }
  89. 1 class Logs < OpenAI::Internal::Type::BaseModel
  90. # @!attribute schema
  91. # The json schema for the run data source items. Learn how to build JSON schemas
  92. # [here](https://json-schema.org/).
  93. #
  94. # @return [Hash{Symbol=>Object}]
  95. 1 required :schema, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  96. # @!attribute type
  97. # The type of data source. Always `logs`.
  98. #
  99. # @return [Symbol, :logs]
  100. 1 required :type, const: :logs
  101. # @!attribute metadata
  102. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  103. # for storing additional information about the object in a structured format, and
  104. # querying for objects via API or the dashboard.
  105. #
  106. # Keys are strings with a maximum length of 64 characters. Values are strings with
  107. # a maximum length of 512 characters.
  108. #
  109. # @return [Hash{Symbol=>String}, nil]
  110. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  111. # @!method initialize(schema:, metadata: nil, type: :logs)
  112. # Some parameter documentations has been truncated, see
  113. # {OpenAI::Models::EvalCreateResponse::DataSourceConfig::Logs} for more details.
  114. #
  115. # A LogsDataSourceConfig which specifies the metadata property of your logs query.
  116. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc. The
  117. # schema returned by this data source config is used to defined what variables are
  118. # available in your evals. `item` and `sample` are both defined when using this
  119. # data source config.
  120. #
  121. # @param schema [Hash{Symbol=>Object}] The json schema for the run data source items.
  122. #
  123. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  124. #
  125. # @param type [Symbol, :logs] The type of data source. Always `logs`.
  126. end
  127. # @!method self.variants
  128. # @return [Array(OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalCreateResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig)]
  129. end
  130. # A LabelModelGrader object which uses a model to assign labels to each item in
  131. # the evaluation.
  132. 1 module TestingCriterion
  133. 1 extend OpenAI::Internal::Type::Union
  134. # A LabelModelGrader object which uses a model to assign labels to each item
  135. # in the evaluation.
  136. 1 variant -> { OpenAI::Graders::LabelModelGrader }
  137. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  138. 1 variant -> { OpenAI::Graders::StringCheckGrader }
  139. # A TextSimilarityGrader object which grades text based on similarity metrics.
  140. 1 variant -> { OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderTextSimilarity }
  141. # A PythonGrader object that runs a python script on the input.
  142. 1 variant -> { OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderPython }
  143. # A ScoreModelGrader object that uses a model to assign a score to the input.
  144. 1 variant -> { OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderScoreModel }
  145. 1 class EvalGraderTextSimilarity < OpenAI::Models::Graders::TextSimilarityGrader
  146. # @!attribute pass_threshold
  147. # The threshold for the score.
  148. #
  149. # @return [Float]
  150. 1 required :pass_threshold, Float
  151. # @!method initialize(pass_threshold:)
  152. # A TextSimilarityGrader object which grades text based on similarity metrics.
  153. #
  154. # @param pass_threshold [Float] The threshold for the score.
  155. end
  156. 1 class EvalGraderPython < OpenAI::Models::Graders::PythonGrader
  157. # @!attribute pass_threshold
  158. # The threshold for the score.
  159. #
  160. # @return [Float, nil]
  161. 1 optional :pass_threshold, Float
  162. # @!method initialize(pass_threshold: nil)
  163. # A PythonGrader object that runs a python script on the input.
  164. #
  165. # @param pass_threshold [Float] The threshold for the score.
  166. end
  167. 1 class EvalGraderScoreModel < OpenAI::Models::Graders::ScoreModelGrader
  168. # @!attribute pass_threshold
  169. # The threshold for the score.
  170. #
  171. # @return [Float, nil]
  172. 1 optional :pass_threshold, Float
  173. # @!method initialize(pass_threshold: nil)
  174. # A ScoreModelGrader object that uses a model to assign a score to the input.
  175. #
  176. # @param pass_threshold [Float] The threshold for the score.
  177. end
  178. # @!method self.variants
  179. # @return [Array(OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalCreateResponse::TestingCriterion::EvalGraderScoreModel)]
  180. end
  181. end
  182. end
  183. end

openai-ruby/lib/openai/models/eval_custom_data_source_config.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class EvalCustomDataSourceConfig < OpenAI::Internal::Type::BaseModel
  5. # @!attribute schema
  6. # The json schema for the run data source items. Learn how to build JSON schemas
  7. # [here](https://json-schema.org/).
  8. #
  9. # @return [Hash{Symbol=>Object}]
  10. 1 required :schema, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  11. # @!attribute type
  12. # The type of data source. Always `custom`.
  13. #
  14. # @return [Symbol, :custom]
  15. 1 required :type, const: :custom
  16. # @!method initialize(schema:, type: :custom)
  17. # Some parameter documentations has been truncated, see
  18. # {OpenAI::Models::EvalCustomDataSourceConfig} for more details.
  19. #
  20. # A CustomDataSourceConfig which specifies the schema of your `item` and
  21. # optionally `sample` namespaces. The response schema defines the shape of the
  22. # data that will be:
  23. #
  24. # - Used to define your testing criteria and
  25. # - What data is required when creating a run
  26. #
  27. # @param schema [Hash{Symbol=>Object}] The json schema for the run data source items.
  28. #
  29. # @param type [Symbol, :custom] The type of data source. Always `custom`.
  30. end
  31. end
  32. end

openai-ruby/lib/openai/models/eval_delete_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#delete
  5. 1 class EvalDeleteParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/eval_delete_response.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#delete
  5. 1 class EvalDeleteResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute deleted
  7. #
  8. # @return [Boolean]
  9. 1 required :deleted, OpenAI::Internal::Type::Boolean
  10. # @!attribute eval_id
  11. #
  12. # @return [String]
  13. 1 required :eval_id, String
  14. # @!attribute object
  15. #
  16. # @return [String]
  17. 1 required :object, String
  18. # @!method initialize(deleted:, eval_id:, object:)
  19. # @param deleted [Boolean]
  20. # @param eval_id [String]
  21. # @param object [String]
  22. end
  23. end
  24. end

openai-ruby/lib/openai/models/eval_list_params.rb

100.0% lines covered

100.0% branches covered

17 relevant lines. 17 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#list
  5. 1 class EvalListParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute after
  9. # Identifier for the last eval from the previous pagination request.
  10. #
  11. # @return [String, nil]
  12. 1 optional :after, String
  13. # @!attribute limit
  14. # Number of evals to retrieve.
  15. #
  16. # @return [Integer, nil]
  17. 1 optional :limit, Integer
  18. # @!attribute order
  19. # Sort order for evals by timestamp. Use `asc` for ascending order or `desc` for
  20. # descending order.
  21. #
  22. # @return [Symbol, OpenAI::Models::EvalListParams::Order, nil]
  23. 1 optional :order, enum: -> { OpenAI::EvalListParams::Order }
  24. # @!attribute order_by
  25. # Evals can be ordered by creation time or last updated time. Use `created_at` for
  26. # creation time or `updated_at` for last updated time.
  27. #
  28. # @return [Symbol, OpenAI::Models::EvalListParams::OrderBy, nil]
  29. 1 optional :order_by, enum: -> { OpenAI::EvalListParams::OrderBy }
  30. # @!method initialize(after: nil, limit: nil, order: nil, order_by: nil, request_options: {})
  31. # Some parameter documentations has been truncated, see
  32. # {OpenAI::Models::EvalListParams} for more details.
  33. #
  34. # @param after [String] Identifier for the last eval from the previous pagination request.
  35. #
  36. # @param limit [Integer] Number of evals to retrieve.
  37. #
  38. # @param order [Symbol, OpenAI::Models::EvalListParams::Order] Sort order for evals by timestamp. Use `asc` for ascending order or `desc` for d
  39. #
  40. # @param order_by [Symbol, OpenAI::Models::EvalListParams::OrderBy] Evals can be ordered by creation time or last updated time. Use
  41. #
  42. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  43. # Sort order for evals by timestamp. Use `asc` for ascending order or `desc` for
  44. # descending order.
  45. 1 module Order
  46. 1 extend OpenAI::Internal::Type::Enum
  47. 1 ASC = :asc
  48. 1 DESC = :desc
  49. # @!method self.values
  50. # @return [Array<Symbol>]
  51. end
  52. # Evals can be ordered by creation time or last updated time. Use `created_at` for
  53. # creation time or `updated_at` for last updated time.
  54. 1 module OrderBy
  55. 1 extend OpenAI::Internal::Type::Enum
  56. 1 CREATED_AT = :created_at
  57. 1 UPDATED_AT = :updated_at
  58. # @!method self.values
  59. # @return [Array<Symbol>]
  60. end
  61. end
  62. end
  63. end

openai-ruby/lib/openai/models/eval_list_response.rb

97.06% lines covered

100.0% branches covered

34 relevant lines. 33 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#list
  5. 1 class EvalListResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # Unique identifier for the evaluation.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) for when the eval was created.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data_source_config
  17. # Configuration of data sources used in runs of the evaluation.
  18. #
  19. # @return [OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalListResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig]
  20. 1 required :data_source_config, union: -> { OpenAI::Models::EvalListResponse::DataSourceConfig }
  21. # @!attribute metadata
  22. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  23. # for storing additional information about the object in a structured format, and
  24. # querying for objects via API or the dashboard.
  25. #
  26. # Keys are strings with a maximum length of 64 characters. Values are strings with
  27. # a maximum length of 512 characters.
  28. #
  29. # @return [Hash{Symbol=>String}, nil]
  30. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  31. # @!attribute name
  32. # The name of the evaluation.
  33. #
  34. # @return [String]
  35. 1 required :name, String
  36. # @!attribute object
  37. # The object type.
  38. #
  39. # @return [Symbol, :eval]
  40. 1 required :object, const: :eval
  41. # @!attribute testing_criteria
  42. # A list of testing criteria.
  43. #
  44. # @return [Array<OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderScoreModel>]
  45. 1 required :testing_criteria,
  46. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Models::EvalListResponse::TestingCriterion] }
  47. # @!method initialize(id:, created_at:, data_source_config:, metadata:, name:, testing_criteria:, object: :eval)
  48. # Some parameter documentations has been truncated, see
  49. # {OpenAI::Models::EvalListResponse} for more details.
  50. #
  51. # An Eval object with a data source config and testing criteria. An Eval
  52. # represents a task to be done for your LLM integration. Like:
  53. #
  54. # - Improve the quality of my chatbot
  55. # - See how well my chatbot handles customer support
  56. # - Check if o4-mini is better at my usecase than gpt-4o
  57. #
  58. # @param id [String] Unique identifier for the evaluation.
  59. #
  60. # @param created_at [Integer] The Unix timestamp (in seconds) for when the eval was created.
  61. #
  62. # @param data_source_config [OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalListResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig] Configuration of data sources used in runs of the evaluation.
  63. #
  64. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  65. #
  66. # @param name [String] The name of the evaluation.
  67. #
  68. # @param testing_criteria [Array<OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderScoreModel>] A list of testing criteria.
  69. #
  70. # @param object [Symbol, :eval] The object type.
  71. # Configuration of data sources used in runs of the evaluation.
  72. #
  73. # @see OpenAI::Models::EvalListResponse#data_source_config
  74. 1 module DataSourceConfig
  75. 1 extend OpenAI::Internal::Type::Union
  76. 1 discriminator :type
  77. # A CustomDataSourceConfig which specifies the schema of your `item` and optionally `sample` namespaces.
  78. # The response schema defines the shape of the data that will be:
  79. # - Used to define your testing criteria and
  80. # - What data is required when creating a run
  81. 1 variant :custom, -> { OpenAI::EvalCustomDataSourceConfig }
  82. # A LogsDataSourceConfig which specifies the metadata property of your logs query.
  83. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.
  84. # The schema returned by this data source config is used to defined what variables are available in your evals.
  85. # `item` and `sample` are both defined when using this data source config.
  86. 1 variant :logs, -> { OpenAI::Models::EvalListResponse::DataSourceConfig::Logs }
  87. # Deprecated in favor of LogsDataSourceConfig.
  88. 1 variant :stored_completions, -> { OpenAI::EvalStoredCompletionsDataSourceConfig }
  89. 1 class Logs < OpenAI::Internal::Type::BaseModel
  90. # @!attribute schema
  91. # The json schema for the run data source items. Learn how to build JSON schemas
  92. # [here](https://json-schema.org/).
  93. #
  94. # @return [Hash{Symbol=>Object}]
  95. 1 required :schema, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  96. # @!attribute type
  97. # The type of data source. Always `logs`.
  98. #
  99. # @return [Symbol, :logs]
  100. 1 required :type, const: :logs
  101. # @!attribute metadata
  102. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  103. # for storing additional information about the object in a structured format, and
  104. # querying for objects via API or the dashboard.
  105. #
  106. # Keys are strings with a maximum length of 64 characters. Values are strings with
  107. # a maximum length of 512 characters.
  108. #
  109. # @return [Hash{Symbol=>String}, nil]
  110. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  111. # @!method initialize(schema:, metadata: nil, type: :logs)
  112. # Some parameter documentations has been truncated, see
  113. # {OpenAI::Models::EvalListResponse::DataSourceConfig::Logs} for more details.
  114. #
  115. # A LogsDataSourceConfig which specifies the metadata property of your logs query.
  116. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc. The
  117. # schema returned by this data source config is used to defined what variables are
  118. # available in your evals. `item` and `sample` are both defined when using this
  119. # data source config.
  120. #
  121. # @param schema [Hash{Symbol=>Object}] The json schema for the run data source items.
  122. #
  123. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  124. #
  125. # @param type [Symbol, :logs] The type of data source. Always `logs`.
  126. end
  127. # @!method self.variants
  128. # @return [Array(OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalListResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig)]
  129. end
  130. # A LabelModelGrader object which uses a model to assign labels to each item in
  131. # the evaluation.
  132. 1 module TestingCriterion
  133. 1 extend OpenAI::Internal::Type::Union
  134. # A LabelModelGrader object which uses a model to assign labels to each item
  135. # in the evaluation.
  136. 1 variant -> { OpenAI::Graders::LabelModelGrader }
  137. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  138. 1 variant -> { OpenAI::Graders::StringCheckGrader }
  139. # A TextSimilarityGrader object which grades text based on similarity metrics.
  140. 1 variant -> { OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderTextSimilarity }
  141. # A PythonGrader object that runs a python script on the input.
  142. 1 variant -> { OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderPython }
  143. # A ScoreModelGrader object that uses a model to assign a score to the input.
  144. 1 variant -> { OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderScoreModel }
  145. 1 class EvalGraderTextSimilarity < OpenAI::Models::Graders::TextSimilarityGrader
  146. # @!attribute pass_threshold
  147. # The threshold for the score.
  148. #
  149. # @return [Float]
  150. 1 required :pass_threshold, Float
  151. # @!method initialize(pass_threshold:)
  152. # A TextSimilarityGrader object which grades text based on similarity metrics.
  153. #
  154. # @param pass_threshold [Float] The threshold for the score.
  155. end
  156. 1 class EvalGraderPython < OpenAI::Models::Graders::PythonGrader
  157. # @!attribute pass_threshold
  158. # The threshold for the score.
  159. #
  160. # @return [Float, nil]
  161. 1 optional :pass_threshold, Float
  162. # @!method initialize(pass_threshold: nil)
  163. # A PythonGrader object that runs a python script on the input.
  164. #
  165. # @param pass_threshold [Float] The threshold for the score.
  166. end
  167. 1 class EvalGraderScoreModel < OpenAI::Models::Graders::ScoreModelGrader
  168. # @!attribute pass_threshold
  169. # The threshold for the score.
  170. #
  171. # @return [Float, nil]
  172. 1 optional :pass_threshold, Float
  173. # @!method initialize(pass_threshold: nil)
  174. # A ScoreModelGrader object that uses a model to assign a score to the input.
  175. #
  176. # @param pass_threshold [Float] The threshold for the score.
  177. end
  178. # @!method self.variants
  179. # @return [Array(OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalListResponse::TestingCriterion::EvalGraderScoreModel)]
  180. end
  181. end
  182. end
  183. end

openai-ruby/lib/openai/models/eval_retrieve_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#retrieve
  5. 1 class EvalRetrieveParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/eval_retrieve_response.rb

97.06% lines covered

100.0% branches covered

34 relevant lines. 33 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#retrieve
  5. 1 class EvalRetrieveResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # Unique identifier for the evaluation.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) for when the eval was created.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data_source_config
  17. # Configuration of data sources used in runs of the evaluation.
  18. #
  19. # @return [OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalRetrieveResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig]
  20. 1 required :data_source_config, union: -> { OpenAI::Models::EvalRetrieveResponse::DataSourceConfig }
  21. # @!attribute metadata
  22. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  23. # for storing additional information about the object in a structured format, and
  24. # querying for objects via API or the dashboard.
  25. #
  26. # Keys are strings with a maximum length of 64 characters. Values are strings with
  27. # a maximum length of 512 characters.
  28. #
  29. # @return [Hash{Symbol=>String}, nil]
  30. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  31. # @!attribute name
  32. # The name of the evaluation.
  33. #
  34. # @return [String]
  35. 1 required :name, String
  36. # @!attribute object
  37. # The object type.
  38. #
  39. # @return [Symbol, :eval]
  40. 1 required :object, const: :eval
  41. # @!attribute testing_criteria
  42. # A list of testing criteria.
  43. #
  44. # @return [Array<OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderScoreModel>]
  45. 1 required :testing_criteria,
  46. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Models::EvalRetrieveResponse::TestingCriterion] }
  47. # @!method initialize(id:, created_at:, data_source_config:, metadata:, name:, testing_criteria:, object: :eval)
  48. # Some parameter documentations has been truncated, see
  49. # {OpenAI::Models::EvalRetrieveResponse} for more details.
  50. #
  51. # An Eval object with a data source config and testing criteria. An Eval
  52. # represents a task to be done for your LLM integration. Like:
  53. #
  54. # - Improve the quality of my chatbot
  55. # - See how well my chatbot handles customer support
  56. # - Check if o4-mini is better at my usecase than gpt-4o
  57. #
  58. # @param id [String] Unique identifier for the evaluation.
  59. #
  60. # @param created_at [Integer] The Unix timestamp (in seconds) for when the eval was created.
  61. #
  62. # @param data_source_config [OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalRetrieveResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig] Configuration of data sources used in runs of the evaluation.
  63. #
  64. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  65. #
  66. # @param name [String] The name of the evaluation.
  67. #
  68. # @param testing_criteria [Array<OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderScoreModel>] A list of testing criteria.
  69. #
  70. # @param object [Symbol, :eval] The object type.
  71. # Configuration of data sources used in runs of the evaluation.
  72. #
  73. # @see OpenAI::Models::EvalRetrieveResponse#data_source_config
  74. 1 module DataSourceConfig
  75. 1 extend OpenAI::Internal::Type::Union
  76. 1 discriminator :type
  77. # A CustomDataSourceConfig which specifies the schema of your `item` and optionally `sample` namespaces.
  78. # The response schema defines the shape of the data that will be:
  79. # - Used to define your testing criteria and
  80. # - What data is required when creating a run
  81. 1 variant :custom, -> { OpenAI::EvalCustomDataSourceConfig }
  82. # A LogsDataSourceConfig which specifies the metadata property of your logs query.
  83. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.
  84. # The schema returned by this data source config is used to defined what variables are available in your evals.
  85. # `item` and `sample` are both defined when using this data source config.
  86. 1 variant :logs, -> { OpenAI::Models::EvalRetrieveResponse::DataSourceConfig::Logs }
  87. # Deprecated in favor of LogsDataSourceConfig.
  88. 1 variant :stored_completions, -> { OpenAI::EvalStoredCompletionsDataSourceConfig }
  89. 1 class Logs < OpenAI::Internal::Type::BaseModel
  90. # @!attribute schema
  91. # The json schema for the run data source items. Learn how to build JSON schemas
  92. # [here](https://json-schema.org/).
  93. #
  94. # @return [Hash{Symbol=>Object}]
  95. 1 required :schema, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  96. # @!attribute type
  97. # The type of data source. Always `logs`.
  98. #
  99. # @return [Symbol, :logs]
  100. 1 required :type, const: :logs
  101. # @!attribute metadata
  102. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  103. # for storing additional information about the object in a structured format, and
  104. # querying for objects via API or the dashboard.
  105. #
  106. # Keys are strings with a maximum length of 64 characters. Values are strings with
  107. # a maximum length of 512 characters.
  108. #
  109. # @return [Hash{Symbol=>String}, nil]
  110. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  111. # @!method initialize(schema:, metadata: nil, type: :logs)
  112. # Some parameter documentations has been truncated, see
  113. # {OpenAI::Models::EvalRetrieveResponse::DataSourceConfig::Logs} for more details.
  114. #
  115. # A LogsDataSourceConfig which specifies the metadata property of your logs query.
  116. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc. The
  117. # schema returned by this data source config is used to defined what variables are
  118. # available in your evals. `item` and `sample` are both defined when using this
  119. # data source config.
  120. #
  121. # @param schema [Hash{Symbol=>Object}] The json schema for the run data source items.
  122. #
  123. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  124. #
  125. # @param type [Symbol, :logs] The type of data source. Always `logs`.
  126. end
  127. # @!method self.variants
  128. # @return [Array(OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalRetrieveResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig)]
  129. end
  130. # A LabelModelGrader object which uses a model to assign labels to each item in
  131. # the evaluation.
  132. 1 module TestingCriterion
  133. 1 extend OpenAI::Internal::Type::Union
  134. # A LabelModelGrader object which uses a model to assign labels to each item
  135. # in the evaluation.
  136. 1 variant -> { OpenAI::Graders::LabelModelGrader }
  137. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  138. 1 variant -> { OpenAI::Graders::StringCheckGrader }
  139. # A TextSimilarityGrader object which grades text based on similarity metrics.
  140. 1 variant -> { OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderTextSimilarity }
  141. # A PythonGrader object that runs a python script on the input.
  142. 1 variant -> { OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderPython }
  143. # A ScoreModelGrader object that uses a model to assign a score to the input.
  144. 1 variant -> { OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderScoreModel }
  145. 1 class EvalGraderTextSimilarity < OpenAI::Models::Graders::TextSimilarityGrader
  146. # @!attribute pass_threshold
  147. # The threshold for the score.
  148. #
  149. # @return [Float]
  150. 1 required :pass_threshold, Float
  151. # @!method initialize(pass_threshold:)
  152. # A TextSimilarityGrader object which grades text based on similarity metrics.
  153. #
  154. # @param pass_threshold [Float] The threshold for the score.
  155. end
  156. 1 class EvalGraderPython < OpenAI::Models::Graders::PythonGrader
  157. # @!attribute pass_threshold
  158. # The threshold for the score.
  159. #
  160. # @return [Float, nil]
  161. 1 optional :pass_threshold, Float
  162. # @!method initialize(pass_threshold: nil)
  163. # A PythonGrader object that runs a python script on the input.
  164. #
  165. # @param pass_threshold [Float] The threshold for the score.
  166. end
  167. 1 class EvalGraderScoreModel < OpenAI::Models::Graders::ScoreModelGrader
  168. # @!attribute pass_threshold
  169. # The threshold for the score.
  170. #
  171. # @return [Float, nil]
  172. 1 optional :pass_threshold, Float
  173. # @!method initialize(pass_threshold: nil)
  174. # A ScoreModelGrader object that uses a model to assign a score to the input.
  175. #
  176. # @param pass_threshold [Float] The threshold for the score.
  177. end
  178. # @!method self.variants
  179. # @return [Array(OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalRetrieveResponse::TestingCriterion::EvalGraderScoreModel)]
  180. end
  181. end
  182. end
  183. end

openai-ruby/lib/openai/models/eval_stored_completions_data_source_config.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @deprecated
  5. 1 class EvalStoredCompletionsDataSourceConfig < OpenAI::Internal::Type::BaseModel
  6. # @!attribute schema
  7. # The json schema for the run data source items. Learn how to build JSON schemas
  8. # [here](https://json-schema.org/).
  9. #
  10. # @return [Hash{Symbol=>Object}]
  11. 1 required :schema, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  12. # @!attribute type
  13. # The type of data source. Always `stored_completions`.
  14. #
  15. # @return [Symbol, :stored_completions]
  16. 1 required :type, const: :stored_completions
  17. # @!attribute metadata
  18. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  19. # for storing additional information about the object in a structured format, and
  20. # querying for objects via API or the dashboard.
  21. #
  22. # Keys are strings with a maximum length of 64 characters. Values are strings with
  23. # a maximum length of 512 characters.
  24. #
  25. # @return [Hash{Symbol=>String}, nil]
  26. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  27. # @!method initialize(schema:, metadata: nil, type: :stored_completions)
  28. # Some parameter documentations has been truncated, see
  29. # {OpenAI::Models::EvalStoredCompletionsDataSourceConfig} for more details.
  30. #
  31. # Deprecated in favor of LogsDataSourceConfig.
  32. #
  33. # @param schema [Hash{Symbol=>Object}] The json schema for the run data source items.
  34. #
  35. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  36. #
  37. # @param type [Symbol, :stored_completions] The type of data source. Always `stored_completions`.
  38. end
  39. end
  40. end

openai-ruby/lib/openai/models/eval_update_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#update
  5. 1 class EvalUpdateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute metadata
  9. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  10. # for storing additional information about the object in a structured format, and
  11. # querying for objects via API or the dashboard.
  12. #
  13. # Keys are strings with a maximum length of 64 characters. Values are strings with
  14. # a maximum length of 512 characters.
  15. #
  16. # @return [Hash{Symbol=>String}, nil]
  17. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  18. # @!attribute name
  19. # Rename the evaluation.
  20. #
  21. # @return [String, nil]
  22. 1 optional :name, String
  23. # @!method initialize(metadata: nil, name: nil, request_options: {})
  24. # Some parameter documentations has been truncated, see
  25. # {OpenAI::Models::EvalUpdateParams} for more details.
  26. #
  27. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  28. #
  29. # @param name [String] Rename the evaluation.
  30. #
  31. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  32. end
  33. end
  34. end

openai-ruby/lib/openai/models/eval_update_response.rb

97.06% lines covered

100.0% branches covered

34 relevant lines. 33 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Evals#update
  5. 1 class EvalUpdateResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # Unique identifier for the evaluation.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) for when the eval was created.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data_source_config
  17. # Configuration of data sources used in runs of the evaluation.
  18. #
  19. # @return [OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalUpdateResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig]
  20. 1 required :data_source_config, union: -> { OpenAI::Models::EvalUpdateResponse::DataSourceConfig }
  21. # @!attribute metadata
  22. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  23. # for storing additional information about the object in a structured format, and
  24. # querying for objects via API or the dashboard.
  25. #
  26. # Keys are strings with a maximum length of 64 characters. Values are strings with
  27. # a maximum length of 512 characters.
  28. #
  29. # @return [Hash{Symbol=>String}, nil]
  30. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  31. # @!attribute name
  32. # The name of the evaluation.
  33. #
  34. # @return [String]
  35. 1 required :name, String
  36. # @!attribute object
  37. # The object type.
  38. #
  39. # @return [Symbol, :eval]
  40. 1 required :object, const: :eval
  41. # @!attribute testing_criteria
  42. # A list of testing criteria.
  43. #
  44. # @return [Array<OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderScoreModel>]
  45. 1 required :testing_criteria,
  46. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Models::EvalUpdateResponse::TestingCriterion] }
  47. # @!method initialize(id:, created_at:, data_source_config:, metadata:, name:, testing_criteria:, object: :eval)
  48. # Some parameter documentations has been truncated, see
  49. # {OpenAI::Models::EvalUpdateResponse} for more details.
  50. #
  51. # An Eval object with a data source config and testing criteria. An Eval
  52. # represents a task to be done for your LLM integration. Like:
  53. #
  54. # - Improve the quality of my chatbot
  55. # - See how well my chatbot handles customer support
  56. # - Check if o4-mini is better at my usecase than gpt-4o
  57. #
  58. # @param id [String] Unique identifier for the evaluation.
  59. #
  60. # @param created_at [Integer] The Unix timestamp (in seconds) for when the eval was created.
  61. #
  62. # @param data_source_config [OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalUpdateResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig] Configuration of data sources used in runs of the evaluation.
  63. #
  64. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  65. #
  66. # @param name [String] The name of the evaluation.
  67. #
  68. # @param testing_criteria [Array<OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderScoreModel>] A list of testing criteria.
  69. #
  70. # @param object [Symbol, :eval] The object type.
  71. # Configuration of data sources used in runs of the evaluation.
  72. #
  73. # @see OpenAI::Models::EvalUpdateResponse#data_source_config
  74. 1 module DataSourceConfig
  75. 1 extend OpenAI::Internal::Type::Union
  76. 1 discriminator :type
  77. # A CustomDataSourceConfig which specifies the schema of your `item` and optionally `sample` namespaces.
  78. # The response schema defines the shape of the data that will be:
  79. # - Used to define your testing criteria and
  80. # - What data is required when creating a run
  81. 1 variant :custom, -> { OpenAI::EvalCustomDataSourceConfig }
  82. # A LogsDataSourceConfig which specifies the metadata property of your logs query.
  83. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc.
  84. # The schema returned by this data source config is used to defined what variables are available in your evals.
  85. # `item` and `sample` are both defined when using this data source config.
  86. 1 variant :logs, -> { OpenAI::Models::EvalUpdateResponse::DataSourceConfig::Logs }
  87. # Deprecated in favor of LogsDataSourceConfig.
  88. 1 variant :stored_completions, -> { OpenAI::EvalStoredCompletionsDataSourceConfig }
  89. 1 class Logs < OpenAI::Internal::Type::BaseModel
  90. # @!attribute schema
  91. # The json schema for the run data source items. Learn how to build JSON schemas
  92. # [here](https://json-schema.org/).
  93. #
  94. # @return [Hash{Symbol=>Object}]
  95. 1 required :schema, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  96. # @!attribute type
  97. # The type of data source. Always `logs`.
  98. #
  99. # @return [Symbol, :logs]
  100. 1 required :type, const: :logs
  101. # @!attribute metadata
  102. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  103. # for storing additional information about the object in a structured format, and
  104. # querying for objects via API or the dashboard.
  105. #
  106. # Keys are strings with a maximum length of 64 characters. Values are strings with
  107. # a maximum length of 512 characters.
  108. #
  109. # @return [Hash{Symbol=>String}, nil]
  110. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  111. # @!method initialize(schema:, metadata: nil, type: :logs)
  112. # Some parameter documentations has been truncated, see
  113. # {OpenAI::Models::EvalUpdateResponse::DataSourceConfig::Logs} for more details.
  114. #
  115. # A LogsDataSourceConfig which specifies the metadata property of your logs query.
  116. # This is usually metadata like `usecase=chatbot` or `prompt-version=v2`, etc. The
  117. # schema returned by this data source config is used to defined what variables are
  118. # available in your evals. `item` and `sample` are both defined when using this
  119. # data source config.
  120. #
  121. # @param schema [Hash{Symbol=>Object}] The json schema for the run data source items.
  122. #
  123. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  124. #
  125. # @param type [Symbol, :logs] The type of data source. Always `logs`.
  126. end
  127. # @!method self.variants
  128. # @return [Array(OpenAI::Models::EvalCustomDataSourceConfig, OpenAI::Models::EvalUpdateResponse::DataSourceConfig::Logs, OpenAI::Models::EvalStoredCompletionsDataSourceConfig)]
  129. end
  130. # A LabelModelGrader object which uses a model to assign labels to each item in
  131. # the evaluation.
  132. 1 module TestingCriterion
  133. 1 extend OpenAI::Internal::Type::Union
  134. # A LabelModelGrader object which uses a model to assign labels to each item
  135. # in the evaluation.
  136. 1 variant -> { OpenAI::Graders::LabelModelGrader }
  137. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  138. 1 variant -> { OpenAI::Graders::StringCheckGrader }
  139. # A TextSimilarityGrader object which grades text based on similarity metrics.
  140. 1 variant -> { OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderTextSimilarity }
  141. # A PythonGrader object that runs a python script on the input.
  142. 1 variant -> { OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderPython }
  143. # A ScoreModelGrader object that uses a model to assign a score to the input.
  144. 1 variant -> { OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderScoreModel }
  145. 1 class EvalGraderTextSimilarity < OpenAI::Models::Graders::TextSimilarityGrader
  146. # @!attribute pass_threshold
  147. # The threshold for the score.
  148. #
  149. # @return [Float]
  150. 1 required :pass_threshold, Float
  151. # @!method initialize(pass_threshold:)
  152. # A TextSimilarityGrader object which grades text based on similarity metrics.
  153. #
  154. # @param pass_threshold [Float] The threshold for the score.
  155. end
  156. 1 class EvalGraderPython < OpenAI::Models::Graders::PythonGrader
  157. # @!attribute pass_threshold
  158. # The threshold for the score.
  159. #
  160. # @return [Float, nil]
  161. 1 optional :pass_threshold, Float
  162. # @!method initialize(pass_threshold: nil)
  163. # A PythonGrader object that runs a python script on the input.
  164. #
  165. # @param pass_threshold [Float] The threshold for the score.
  166. end
  167. 1 class EvalGraderScoreModel < OpenAI::Models::Graders::ScoreModelGrader
  168. # @!attribute pass_threshold
  169. # The threshold for the score.
  170. #
  171. # @return [Float, nil]
  172. 1 optional :pass_threshold, Float
  173. # @!method initialize(pass_threshold: nil)
  174. # A ScoreModelGrader object that uses a model to assign a score to the input.
  175. #
  176. # @param pass_threshold [Float] The threshold for the score.
  177. end
  178. # @!method self.variants
  179. # @return [Array(OpenAI::Models::Graders::LabelModelGrader, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderTextSimilarity, OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderPython, OpenAI::Models::EvalUpdateResponse::TestingCriterion::EvalGraderScoreModel)]
  180. end
  181. end
  182. end
  183. end

openai-ruby/lib/openai/models/evals/create_eval_completions_run_data_source.rb

88.24% lines covered

100.0% branches covered

102 relevant lines. 90 lines covered and 12 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. 1 class CreateEvalCompletionsRunDataSource < OpenAI::Internal::Type::BaseModel
  6. # @!attribute source
  7. # Determines what populates the `item` namespace in this run's data source.
  8. #
  9. # @return [OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::FileContent, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::FileID, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::StoredCompletions]
  10. 1 required :source, union: -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource::Source }
  11. # @!attribute type
  12. # The type of run data source. Always `completions`.
  13. #
  14. # @return [Symbol, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Type]
  15. 1 required :type, enum: -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource::Type }
  16. # @!attribute input_messages
  17. # Used when sampling from a model. Dictates the structure of the messages passed
  18. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  19. # `item.input_trajectory`), or a template with variable references to the `item`
  20. # namespace.
  21. #
  22. # @return [OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::ItemReference, nil]
  23. 1 optional :input_messages,
  24. union: -> {
  25. OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages
  26. }
  27. # @!attribute model
  28. # The name of the model to use for generating completions (e.g. "o3-mini").
  29. #
  30. # @return [String, nil]
  31. 1 optional :model, String
  32. # @!attribute sampling_params
  33. #
  34. # @return [OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams, nil]
  35. 1 optional :sampling_params, -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource::SamplingParams }
  36. # @!method initialize(source:, type:, input_messages: nil, model: nil, sampling_params: nil)
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource} for more details.
  39. #
  40. # A CompletionsRunDataSource object describing a model sampling configuration.
  41. #
  42. # @param source [OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::FileContent, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::FileID, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::StoredCompletions] Determines what populates the `item` namespace in this run's data source.
  43. #
  44. # @param type [Symbol, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Type] The type of run data source. Always `completions`.
  45. #
  46. # @param input_messages [OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::ItemReference] Used when sampling from a model. Dictates the structure of the messages passed i
  47. #
  48. # @param model [String] The name of the model to use for generating completions (e.g. "o3-mini").
  49. #
  50. # @param sampling_params [OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams]
  51. # Determines what populates the `item` namespace in this run's data source.
  52. #
  53. # @see OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource#source
  54. 1 module Source
  55. 1 extend OpenAI::Internal::Type::Union
  56. 1 discriminator :type
  57. 1 variant :file_content, -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource::Source::FileContent }
  58. 1 variant :file_id, -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource::Source::FileID }
  59. # A StoredCompletionsRunDataSource configuration describing a set of filters
  60. 1 variant :stored_completions,
  61. -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource::Source::StoredCompletions }
  62. 1 class FileContent < OpenAI::Internal::Type::BaseModel
  63. # @!attribute content
  64. # The content of the jsonl file.
  65. #
  66. # @return [Array<OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::FileContent::Content>]
  67. 1 required :content,
  68. -> {
  69. OpenAI::Internal::Type::ArrayOf[OpenAI::Evals::CreateEvalCompletionsRunDataSource::Source::FileContent::Content]
  70. }
  71. # @!attribute type
  72. # The type of jsonl source. Always `file_content`.
  73. #
  74. # @return [Symbol, :file_content]
  75. 1 required :type, const: :file_content
  76. # @!method initialize(content:, type: :file_content)
  77. # @param content [Array<OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::FileContent::Content>] The content of the jsonl file.
  78. #
  79. # @param type [Symbol, :file_content] The type of jsonl source. Always `file_content`.
  80. 1 class Content < OpenAI::Internal::Type::BaseModel
  81. # @!attribute item
  82. #
  83. # @return [Hash{Symbol=>Object}]
  84. 1 required :item, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  85. # @!attribute sample
  86. #
  87. # @return [Hash{Symbol=>Object}, nil]
  88. 1 optional :sample, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  89. # @!method initialize(item:, sample: nil)
  90. # @param item [Hash{Symbol=>Object}]
  91. # @param sample [Hash{Symbol=>Object}]
  92. end
  93. end
  94. 1 class FileID < OpenAI::Internal::Type::BaseModel
  95. # @!attribute id
  96. # The identifier of the file.
  97. #
  98. # @return [String]
  99. 1 required :id, String
  100. # @!attribute type
  101. # The type of jsonl source. Always `file_id`.
  102. #
  103. # @return [Symbol, :file_id]
  104. 1 required :type, const: :file_id
  105. # @!method initialize(id:, type: :file_id)
  106. # @param id [String] The identifier of the file.
  107. #
  108. # @param type [Symbol, :file_id] The type of jsonl source. Always `file_id`.
  109. end
  110. 1 class StoredCompletions < OpenAI::Internal::Type::BaseModel
  111. # @!attribute type
  112. # The type of source. Always `stored_completions`.
  113. #
  114. # @return [Symbol, :stored_completions]
  115. 1 required :type, const: :stored_completions
  116. # @!attribute created_after
  117. # An optional Unix timestamp to filter items created after this time.
  118. #
  119. # @return [Integer, nil]
  120. 1 optional :created_after, Integer, nil?: true
  121. # @!attribute created_before
  122. # An optional Unix timestamp to filter items created before this time.
  123. #
  124. # @return [Integer, nil]
  125. 1 optional :created_before, Integer, nil?: true
  126. # @!attribute limit
  127. # An optional maximum number of items to return.
  128. #
  129. # @return [Integer, nil]
  130. 1 optional :limit, Integer, nil?: true
  131. # @!attribute metadata
  132. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  133. # for storing additional information about the object in a structured format, and
  134. # querying for objects via API or the dashboard.
  135. #
  136. # Keys are strings with a maximum length of 64 characters. Values are strings with
  137. # a maximum length of 512 characters.
  138. #
  139. # @return [Hash{Symbol=>String}, nil]
  140. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  141. # @!attribute model
  142. # An optional model to filter by (e.g., 'gpt-4o').
  143. #
  144. # @return [String, nil]
  145. 1 optional :model, String, nil?: true
  146. # @!method initialize(created_after: nil, created_before: nil, limit: nil, metadata: nil, model: nil, type: :stored_completions)
  147. # Some parameter documentations has been truncated, see
  148. # {OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::StoredCompletions}
  149. # for more details.
  150. #
  151. # A StoredCompletionsRunDataSource configuration describing a set of filters
  152. #
  153. # @param created_after [Integer, nil] An optional Unix timestamp to filter items created after this time.
  154. #
  155. # @param created_before [Integer, nil] An optional Unix timestamp to filter items created before this time.
  156. #
  157. # @param limit [Integer, nil] An optional maximum number of items to return.
  158. #
  159. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  160. #
  161. # @param model [String, nil] An optional model to filter by (e.g., 'gpt-4o').
  162. #
  163. # @param type [Symbol, :stored_completions] The type of source. Always `stored_completions`.
  164. end
  165. # @!method self.variants
  166. # @return [Array(OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::FileContent, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::FileID, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::Source::StoredCompletions)]
  167. end
  168. # The type of run data source. Always `completions`.
  169. #
  170. # @see OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource#type
  171. 1 module Type
  172. 1 extend OpenAI::Internal::Type::Enum
  173. 1 COMPLETIONS = :completions
  174. # @!method self.values
  175. # @return [Array<Symbol>]
  176. end
  177. # Used when sampling from a model. Dictates the structure of the messages passed
  178. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  179. # `item.input_trajectory`), or a template with variable references to the `item`
  180. # namespace.
  181. #
  182. # @see OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource#input_messages
  183. 1 module InputMessages
  184. 1 extend OpenAI::Internal::Type::Union
  185. 1 discriminator :type
  186. 1 variant :template, -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template }
  187. 1 variant :item_reference,
  188. -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages::ItemReference }
  189. 1 class Template < OpenAI::Internal::Type::BaseModel
  190. # @!attribute template
  191. # A list of chat messages forming the prompt or context. May include variable
  192. # references to the `item` namespace, ie {{item.name}}.
  193. #
  194. # @return [Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message>]
  195. 1 required :template,
  196. -> {
  197. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template]
  198. }
  199. # @!attribute type
  200. # The type of input messages. Always `template`.
  201. #
  202. # @return [Symbol, :template]
  203. 1 required :type, const: :template
  204. # @!method initialize(template:, type: :template)
  205. # Some parameter documentations has been truncated, see
  206. # {OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template}
  207. # for more details.
  208. #
  209. # @param template [Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message>] A list of chat messages forming the prompt or context. May include variable refe
  210. #
  211. # @param type [Symbol, :template] The type of input messages. Always `template`.
  212. # A message input to the model with a role indicating instruction following
  213. # hierarchy. Instructions given with the `developer` or `system` role take
  214. # precedence over instructions given with the `user` role. Messages with the
  215. # `assistant` role are presumed to have been generated by the model in previous
  216. # interactions.
  217. 1 module Template
  218. 1 extend OpenAI::Internal::Type::Union
  219. 1 discriminator :type
  220. # A message input to the model with a role indicating instruction following
  221. # hierarchy. Instructions given with the `developer` or `system` role take
  222. # precedence over instructions given with the `user` role. Messages with the
  223. # `assistant` role are presumed to have been generated by the model in previous
  224. # interactions.
  225. 1 variant :message, -> { OpenAI::Responses::EasyInputMessage }
  226. # A message input to the model with a role indicating instruction following
  227. # hierarchy. Instructions given with the `developer` or `system` role take
  228. # precedence over instructions given with the `user` role. Messages with the
  229. # `assistant` role are presumed to have been generated by the model in previous
  230. # interactions.
  231. 1 variant :message,
  232. -> {
  233. OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message
  234. }
  235. 1 class Message < OpenAI::Internal::Type::BaseModel
  236. # @!attribute content
  237. # Inputs to the model - can contain template strings.
  238. #
  239. # @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::OutputText, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::InputImage, Array<Object>]
  240. 1 required :content,
  241. union: -> {
  242. OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content
  243. }
  244. # @!attribute role
  245. # The role of the message input. One of `user`, `assistant`, `system`, or
  246. # `developer`.
  247. #
  248. # @return [Symbol, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Role]
  249. 1 required :role,
  250. enum: -> {
  251. OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Role
  252. }
  253. # @!attribute type
  254. # The type of the message input. Always `message`.
  255. #
  256. # @return [Symbol, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Type, nil]
  257. 1 optional :type,
  258. enum: -> {
  259. OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Type
  260. }
  261. # @!method initialize(content:, role:, type: nil)
  262. # Some parameter documentations has been truncated, see
  263. # {OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message}
  264. # for more details.
  265. #
  266. # A message input to the model with a role indicating instruction following
  267. # hierarchy. Instructions given with the `developer` or `system` role take
  268. # precedence over instructions given with the `user` role. Messages with the
  269. # `assistant` role are presumed to have been generated by the model in previous
  270. # interactions.
  271. #
  272. # @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::OutputText, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::InputImage, Array<Object>] Inputs to the model - can contain template strings.
  273. #
  274. # @param role [Symbol, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  275. #
  276. # @param type [Symbol, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Type] The type of the message input. Always `message`.
  277. # Inputs to the model - can contain template strings.
  278. #
  279. # @see OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message#content
  280. 1 module Content
  281. 1 extend OpenAI::Internal::Type::Union
  282. # A text input to the model.
  283. 1 variant String
  284. # A text input to the model.
  285. 1 variant -> { OpenAI::Responses::ResponseInputText }
  286. # A text output from the model.
  287. 1 variant -> {
  288. OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::OutputText
  289. }
  290. # An image input to the model.
  291. 1 variant -> {
  292. OpenAI::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::InputImage
  293. }
  294. # A list of inputs, each of which may be either an input text or input image object.
  295. 1 variant -> { OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::AnArrayOfInputTextAndInputImageArray }
  296. 1 class OutputText < OpenAI::Internal::Type::BaseModel
  297. # @!attribute text
  298. # The text output from the model.
  299. #
  300. # @return [String]
  301. 1 required :text, String
  302. # @!attribute type
  303. # The type of the output text. Always `output_text`.
  304. #
  305. # @return [Symbol, :output_text]
  306. 1 required :type, const: :output_text
  307. # @!method initialize(text:, type: :output_text)
  308. # Some parameter documentations has been truncated, see
  309. # {OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::OutputText}
  310. # for more details.
  311. #
  312. # A text output from the model.
  313. #
  314. # @param text [String] The text output from the model.
  315. #
  316. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  317. end
  318. 1 class InputImage < OpenAI::Internal::Type::BaseModel
  319. # @!attribute image_url
  320. # The URL of the image input.
  321. #
  322. # @return [String]
  323. 1 required :image_url, String
  324. # @!attribute type
  325. # The type of the image input. Always `input_image`.
  326. #
  327. # @return [Symbol, :input_image]
  328. 1 required :type, const: :input_image
  329. # @!attribute detail
  330. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  331. # `auto`. Defaults to `auto`.
  332. #
  333. # @return [String, nil]
  334. 1 optional :detail, String
  335. # @!method initialize(image_url:, detail: nil, type: :input_image)
  336. # Some parameter documentations has been truncated, see
  337. # {OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::InputImage}
  338. # for more details.
  339. #
  340. # An image input to the model.
  341. #
  342. # @param image_url [String] The URL of the image input.
  343. #
  344. # @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
  345. #
  346. # @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
  347. end
  348. # @!method self.variants
  349. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::OutputText, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message::Content::InputImage, Array<Object>)]
  350. # @type [OpenAI::Internal::Type::Converter]
  351. 1 AnArrayOfInputTextAndInputImageArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
  352. end
  353. # The role of the message input. One of `user`, `assistant`, `system`, or
  354. # `developer`.
  355. #
  356. # @see OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message#role
  357. 1 module Role
  358. 1 extend OpenAI::Internal::Type::Enum
  359. 1 USER = :user
  360. 1 ASSISTANT = :assistant
  361. 1 SYSTEM = :system
  362. 1 DEVELOPER = :developer
  363. # @!method self.values
  364. # @return [Array<Symbol>]
  365. end
  366. # The type of the message input. Always `message`.
  367. #
  368. # @see OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message#type
  369. 1 module Type
  370. 1 extend OpenAI::Internal::Type::Enum
  371. 1 MESSAGE = :message
  372. # @!method self.values
  373. # @return [Array<Symbol>]
  374. end
  375. end
  376. # @!method self.variants
  377. # @return [Array(OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template::Template::Message)]
  378. end
  379. end
  380. 1 class ItemReference < OpenAI::Internal::Type::BaseModel
  381. # @!attribute item_reference
  382. # A reference to a variable in the `item` namespace. Ie, "item.input_trajectory"
  383. #
  384. # @return [String]
  385. 1 required :item_reference, String
  386. # @!attribute type
  387. # The type of input messages. Always `item_reference`.
  388. #
  389. # @return [Symbol, :item_reference]
  390. 1 required :type, const: :item_reference
  391. # @!method initialize(item_reference:, type: :item_reference)
  392. # @param item_reference [String] A reference to a variable in the `item` namespace. Ie, "item.input_trajectory"
  393. #
  394. # @param type [Symbol, :item_reference] The type of input messages. Always `item_reference`.
  395. end
  396. # @!method self.variants
  397. # @return [Array(OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::Template, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::InputMessages::ItemReference)]
  398. end
  399. # @see OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource#sampling_params
  400. 1 class SamplingParams < OpenAI::Internal::Type::BaseModel
  401. # @!attribute max_completion_tokens
  402. # The maximum number of tokens in the generated output.
  403. #
  404. # @return [Integer, nil]
  405. 1 optional :max_completion_tokens, Integer
  406. # @!attribute response_format
  407. # An object specifying the format that the model must output.
  408. #
  409. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  410. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  411. # in the
  412. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  413. #
  414. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  415. # ensures the message the model generates is valid JSON. Using `json_schema` is
  416. # preferred for models that support it.
  417. #
  418. # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject, nil]
  419. 1 optional :response_format,
  420. union: -> {
  421. OpenAI::Evals::CreateEvalCompletionsRunDataSource::SamplingParams::ResponseFormat
  422. }
  423. # @!attribute seed
  424. # A seed value to initialize the randomness, during sampling.
  425. #
  426. # @return [Integer, nil]
  427. 1 optional :seed, Integer
  428. # @!attribute temperature
  429. # A higher temperature increases randomness in the outputs.
  430. #
  431. # @return [Float, nil]
  432. 1 optional :temperature, Float
  433. # @!attribute tools
  434. # A list of tools the model may call. Currently, only functions are supported as a
  435. # tool. Use this to provide a list of functions the model may generate JSON inputs
  436. # for. A max of 128 functions are supported.
  437. #
  438. # @return [Array<OpenAI::Models::Chat::ChatCompletionTool>, nil]
  439. 1 optional :tools, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Chat::ChatCompletionTool] }
  440. # @!attribute top_p
  441. # An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  442. #
  443. # @return [Float, nil]
  444. 1 optional :top_p, Float
  445. # @!method initialize(max_completion_tokens: nil, response_format: nil, seed: nil, temperature: nil, tools: nil, top_p: nil)
  446. # Some parameter documentations has been truncated, see
  447. # {OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams} for
  448. # more details.
  449. #
  450. # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output.
  451. #
  452. # @param response_format [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  453. #
  454. # @param seed [Integer] A seed value to initialize the randomness, during sampling.
  455. #
  456. # @param temperature [Float] A higher temperature increases randomness in the outputs.
  457. #
  458. # @param tools [Array<OpenAI::Models::Chat::ChatCompletionTool>] A list of tools the model may call. Currently, only functions are supported as a
  459. #
  460. # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  461. # An object specifying the format that the model must output.
  462. #
  463. # Setting to `{ "type": "json_schema", "json_schema": {...} }` enables Structured
  464. # Outputs which ensures the model will match your supplied JSON schema. Learn more
  465. # in the
  466. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  467. #
  468. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  469. # ensures the message the model generates is valid JSON. Using `json_schema` is
  470. # preferred for models that support it.
  471. #
  472. # @see OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource::SamplingParams#response_format
  473. 1 module ResponseFormat
  474. 1 extend OpenAI::Internal::Type::Union
  475. # Default response format. Used to generate text responses.
  476. 1 variant -> { OpenAI::ResponseFormatText }
  477. # JSON Schema response format. Used to generate structured JSON responses.
  478. # Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
  479. 1 variant -> { OpenAI::ResponseFormatJSONSchema }
  480. # JSON object response format. An older method of generating JSON responses.
  481. # Using `json_schema` is recommended for models that support it. Note that the
  482. # model will not generate JSON without a system or user message instructing it
  483. # to do so.
  484. 1 variant -> { OpenAI::ResponseFormatJSONObject }
  485. # @!method self.variants
  486. # @return [Array(OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject)]
  487. end
  488. end
  489. end
  490. end
  491. end
  492. end

openai-ruby/lib/openai/models/evals/create_eval_jsonl_run_data_source.rb

95.24% lines covered

100.0% branches covered

21 relevant lines. 20 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. 1 class CreateEvalJSONLRunDataSource < OpenAI::Internal::Type::BaseModel
  6. # @!attribute source
  7. # Determines what populates the `item` namespace in the data source.
  8. #
  9. # @return [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource::Source::FileContent, OpenAI::Models::Evals::CreateEvalJSONLRunDataSource::Source::FileID]
  10. 1 required :source, union: -> { OpenAI::Evals::CreateEvalJSONLRunDataSource::Source }
  11. # @!attribute type
  12. # The type of data source. Always `jsonl`.
  13. #
  14. # @return [Symbol, :jsonl]
  15. 1 required :type, const: :jsonl
  16. # @!method initialize(source:, type: :jsonl)
  17. # A JsonlRunDataSource object with that specifies a JSONL file that matches the
  18. # eval
  19. #
  20. # @param source [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource::Source::FileContent, OpenAI::Models::Evals::CreateEvalJSONLRunDataSource::Source::FileID] Determines what populates the `item` namespace in the data source.
  21. #
  22. # @param type [Symbol, :jsonl] The type of data source. Always `jsonl`.
  23. # Determines what populates the `item` namespace in the data source.
  24. #
  25. # @see OpenAI::Models::Evals::CreateEvalJSONLRunDataSource#source
  26. 1 module Source
  27. 1 extend OpenAI::Internal::Type::Union
  28. 1 discriminator :type
  29. 1 variant :file_content, -> { OpenAI::Evals::CreateEvalJSONLRunDataSource::Source::FileContent }
  30. 1 variant :file_id, -> { OpenAI::Evals::CreateEvalJSONLRunDataSource::Source::FileID }
  31. 1 class FileContent < OpenAI::Internal::Type::BaseModel
  32. # @!attribute content
  33. # The content of the jsonl file.
  34. #
  35. # @return [Array<OpenAI::Models::Evals::CreateEvalJSONLRunDataSource::Source::FileContent::Content>]
  36. 1 required :content,
  37. -> {
  38. OpenAI::Internal::Type::ArrayOf[OpenAI::Evals::CreateEvalJSONLRunDataSource::Source::FileContent::Content]
  39. }
  40. # @!attribute type
  41. # The type of jsonl source. Always `file_content`.
  42. #
  43. # @return [Symbol, :file_content]
  44. 1 required :type, const: :file_content
  45. # @!method initialize(content:, type: :file_content)
  46. # @param content [Array<OpenAI::Models::Evals::CreateEvalJSONLRunDataSource::Source::FileContent::Content>] The content of the jsonl file.
  47. #
  48. # @param type [Symbol, :file_content] The type of jsonl source. Always `file_content`.
  49. 1 class Content < OpenAI::Internal::Type::BaseModel
  50. # @!attribute item
  51. #
  52. # @return [Hash{Symbol=>Object}]
  53. 1 required :item, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  54. # @!attribute sample
  55. #
  56. # @return [Hash{Symbol=>Object}, nil]
  57. 1 optional :sample, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  58. # @!method initialize(item:, sample: nil)
  59. # @param item [Hash{Symbol=>Object}]
  60. # @param sample [Hash{Symbol=>Object}]
  61. end
  62. end
  63. 1 class FileID < OpenAI::Internal::Type::BaseModel
  64. # @!attribute id
  65. # The identifier of the file.
  66. #
  67. # @return [String]
  68. 1 required :id, String
  69. # @!attribute type
  70. # The type of jsonl source. Always `file_id`.
  71. #
  72. # @return [Symbol, :file_id]
  73. 1 required :type, const: :file_id
  74. # @!method initialize(id:, type: :file_id)
  75. # @param id [String] The identifier of the file.
  76. #
  77. # @param type [Symbol, :file_id] The type of jsonl source. Always `file_id`.
  78. end
  79. # @!method self.variants
  80. # @return [Array(OpenAI::Models::Evals::CreateEvalJSONLRunDataSource::Source::FileContent, OpenAI::Models::Evals::CreateEvalJSONLRunDataSource::Source::FileID)]
  81. end
  82. end
  83. end
  84. end
  85. end

openai-ruby/lib/openai/models/evals/eval_api_error.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. 1 class EvalAPIError < OpenAI::Internal::Type::BaseModel
  6. # @!attribute code
  7. # The error code.
  8. #
  9. # @return [String]
  10. 1 required :code, String
  11. # @!attribute message
  12. # The error message.
  13. #
  14. # @return [String]
  15. 1 required :message, String
  16. # @!method initialize(code:, message:)
  17. # An object representing an error response from the Eval API.
  18. #
  19. # @param code [String] The error code.
  20. #
  21. # @param message [String] The error message.
  22. end
  23. end
  24. 1 EvalAPIError = Evals::EvalAPIError
  25. end
  26. end

openai-ruby/lib/openai/models/evals/run_cancel_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#cancel
  6. 1 class RunCancelParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute eval_id
  10. #
  11. # @return [String]
  12. 1 required :eval_id, String
  13. # @!method initialize(eval_id:, request_options: {})
  14. # @param eval_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/evals/run_cancel_response.rb

89.51% lines covered

100.0% branches covered

143 relevant lines. 128 lines covered and 15 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#cancel
  6. 1 class RunCancelResponse < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # Unique identifier for the evaluation run.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # Unix timestamp (in seconds) when the evaluation run was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute data_source
  18. # Information about the run's data source.
  19. #
  20. # @return [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses]
  21. 1 required :data_source, union: -> { OpenAI::Models::Evals::RunCancelResponse::DataSource }
  22. # @!attribute error
  23. # An object representing an error response from the Eval API.
  24. #
  25. # @return [OpenAI::Models::Evals::EvalAPIError]
  26. 1 required :error, -> { OpenAI::Evals::EvalAPIError }
  27. # @!attribute eval_id
  28. # The identifier of the associated evaluation.
  29. #
  30. # @return [String]
  31. 1 required :eval_id, String
  32. # @!attribute metadata
  33. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  34. # for storing additional information about the object in a structured format, and
  35. # querying for objects via API or the dashboard.
  36. #
  37. # Keys are strings with a maximum length of 64 characters. Values are strings with
  38. # a maximum length of 512 characters.
  39. #
  40. # @return [Hash{Symbol=>String}, nil]
  41. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  42. # @!attribute model
  43. # The model that is evaluated, if applicable.
  44. #
  45. # @return [String]
  46. 1 required :model, String
  47. # @!attribute name
  48. # The name of the evaluation run.
  49. #
  50. # @return [String]
  51. 1 required :name, String
  52. # @!attribute object
  53. # The type of the object. Always "eval.run".
  54. #
  55. # @return [Symbol, :"eval.run"]
  56. 1 required :object, const: :"eval.run"
  57. # @!attribute per_model_usage
  58. # Usage statistics for each model during the evaluation run.
  59. #
  60. # @return [Array<OpenAI::Models::Evals::RunCancelResponse::PerModelUsage>]
  61. 1 required :per_model_usage,
  62. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunCancelResponse::PerModelUsage] }
  63. # @!attribute per_testing_criteria_results
  64. # Results per testing criteria applied during the evaluation run.
  65. #
  66. # @return [Array<OpenAI::Models::Evals::RunCancelResponse::PerTestingCriteriaResult>]
  67. 1 required :per_testing_criteria_results,
  68. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunCancelResponse::PerTestingCriteriaResult] }
  69. # @!attribute report_url
  70. # The URL to the rendered evaluation run report on the UI dashboard.
  71. #
  72. # @return [String]
  73. 1 required :report_url, String
  74. # @!attribute result_counts
  75. # Counters summarizing the outcomes of the evaluation run.
  76. #
  77. # @return [OpenAI::Models::Evals::RunCancelResponse::ResultCounts]
  78. 1 required :result_counts, -> { OpenAI::Models::Evals::RunCancelResponse::ResultCounts }
  79. # @!attribute status
  80. # The status of the evaluation run.
  81. #
  82. # @return [String]
  83. 1 required :status, String
  84. # @!method initialize(id:, created_at:, data_source:, error:, eval_id:, metadata:, model:, name:, per_model_usage:, per_testing_criteria_results:, report_url:, result_counts:, status:, object: :"eval.run")
  85. # Some parameter documentations has been truncated, see
  86. # {OpenAI::Models::Evals::RunCancelResponse} for more details.
  87. #
  88. # A schema representing an evaluation run.
  89. #
  90. # @param id [String] Unique identifier for the evaluation run.
  91. #
  92. # @param created_at [Integer] Unix timestamp (in seconds) when the evaluation run was created.
  93. #
  94. # @param data_source [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses] Information about the run's data source.
  95. #
  96. # @param error [OpenAI::Models::Evals::EvalAPIError] An object representing an error response from the Eval API.
  97. #
  98. # @param eval_id [String] The identifier of the associated evaluation.
  99. #
  100. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  101. #
  102. # @param model [String] The model that is evaluated, if applicable.
  103. #
  104. # @param name [String] The name of the evaluation run.
  105. #
  106. # @param per_model_usage [Array<OpenAI::Models::Evals::RunCancelResponse::PerModelUsage>] Usage statistics for each model during the evaluation run.
  107. #
  108. # @param per_testing_criteria_results [Array<OpenAI::Models::Evals::RunCancelResponse::PerTestingCriteriaResult>] Results per testing criteria applied during the evaluation run.
  109. #
  110. # @param report_url [String] The URL to the rendered evaluation run report on the UI dashboard.
  111. #
  112. # @param result_counts [OpenAI::Models::Evals::RunCancelResponse::ResultCounts] Counters summarizing the outcomes of the evaluation run.
  113. #
  114. # @param status [String] The status of the evaluation run.
  115. #
  116. # @param object [Symbol, :"eval.run"] The type of the object. Always "eval.run".
  117. # Information about the run's data source.
  118. #
  119. # @see OpenAI::Models::Evals::RunCancelResponse#data_source
  120. 1 module DataSource
  121. 1 extend OpenAI::Internal::Type::Union
  122. 1 discriminator :type
  123. # A JsonlRunDataSource object with that specifies a JSONL file that matches the eval
  124. 1 variant :jsonl, -> { OpenAI::Evals::CreateEvalJSONLRunDataSource }
  125. # A CompletionsRunDataSource object describing a model sampling configuration.
  126. 1 variant :completions, -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource }
  127. # A ResponsesRunDataSource object describing a model sampling configuration.
  128. 1 variant :responses, -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses }
  129. 1 class Responses < OpenAI::Internal::Type::BaseModel
  130. # @!attribute source
  131. # Determines what populates the `item` namespace in this run's data source.
  132. #
  133. # @return [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::Responses]
  134. 1 required :source, union: -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source }
  135. # @!attribute type
  136. # The type of run data source. Always `responses`.
  137. #
  138. # @return [Symbol, :responses]
  139. 1 required :type, const: :responses
  140. # @!attribute input_messages
  141. # Used when sampling from a model. Dictates the structure of the messages passed
  142. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  143. # `item.input_trajectory`), or a template with variable references to the `item`
  144. # namespace.
  145. #
  146. # @return [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::ItemReference, nil]
  147. 1 optional :input_messages,
  148. union: -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages }
  149. # @!attribute model
  150. # The name of the model to use for generating completions (e.g. "o3-mini").
  151. #
  152. # @return [String, nil]
  153. 1 optional :model, String
  154. # @!attribute sampling_params
  155. #
  156. # @return [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams, nil]
  157. 1 optional :sampling_params,
  158. -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams }
  159. # @!method initialize(source:, input_messages: nil, model: nil, sampling_params: nil, type: :responses)
  160. # Some parameter documentations has been truncated, see
  161. # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses} for more
  162. # details.
  163. #
  164. # A ResponsesRunDataSource object describing a model sampling configuration.
  165. #
  166. # @param source [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::Responses] Determines what populates the `item` namespace in this run's data source.
  167. #
  168. # @param input_messages [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::ItemReference] Used when sampling from a model. Dictates the structure of the messages passed i
  169. #
  170. # @param model [String] The name of the model to use for generating completions (e.g. "o3-mini").
  171. #
  172. # @param sampling_params [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams]
  173. #
  174. # @param type [Symbol, :responses] The type of run data source. Always `responses`.
  175. # Determines what populates the `item` namespace in this run's data source.
  176. #
  177. # @see OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses#source
  178. 1 module Source
  179. 1 extend OpenAI::Internal::Type::Union
  180. 1 discriminator :type
  181. 1 variant :file_content,
  182. -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileContent }
  183. 1 variant :file_id, -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileID }
  184. # A EvalResponsesSource object describing a run data source configuration.
  185. 1 variant :responses,
  186. -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::Responses }
  187. 1 class FileContent < OpenAI::Internal::Type::BaseModel
  188. # @!attribute content
  189. # The content of the jsonl file.
  190. #
  191. # @return [Array<OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileContent::Content>]
  192. 1 required :content,
  193. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileContent::Content] }
  194. # @!attribute type
  195. # The type of jsonl source. Always `file_content`.
  196. #
  197. # @return [Symbol, :file_content]
  198. 1 required :type, const: :file_content
  199. # @!method initialize(content:, type: :file_content)
  200. # @param content [Array<OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileContent::Content>] The content of the jsonl file.
  201. #
  202. # @param type [Symbol, :file_content] The type of jsonl source. Always `file_content`.
  203. 1 class Content < OpenAI::Internal::Type::BaseModel
  204. # @!attribute item
  205. #
  206. # @return [Hash{Symbol=>Object}]
  207. 1 required :item, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  208. # @!attribute sample
  209. #
  210. # @return [Hash{Symbol=>Object}, nil]
  211. 1 optional :sample, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  212. # @!method initialize(item:, sample: nil)
  213. # @param item [Hash{Symbol=>Object}]
  214. # @param sample [Hash{Symbol=>Object}]
  215. end
  216. end
  217. 1 class FileID < OpenAI::Internal::Type::BaseModel
  218. # @!attribute id
  219. # The identifier of the file.
  220. #
  221. # @return [String]
  222. 1 required :id, String
  223. # @!attribute type
  224. # The type of jsonl source. Always `file_id`.
  225. #
  226. # @return [Symbol, :file_id]
  227. 1 required :type, const: :file_id
  228. # @!method initialize(id:, type: :file_id)
  229. # @param id [String] The identifier of the file.
  230. #
  231. # @param type [Symbol, :file_id] The type of jsonl source. Always `file_id`.
  232. end
  233. 1 class Responses < OpenAI::Internal::Type::BaseModel
  234. # @!attribute type
  235. # The type of run data source. Always `responses`.
  236. #
  237. # @return [Symbol, :responses]
  238. 1 required :type, const: :responses
  239. # @!attribute created_after
  240. # Only include items created after this timestamp (inclusive). This is a query
  241. # parameter used to select responses.
  242. #
  243. # @return [Integer, nil]
  244. 1 optional :created_after, Integer, nil?: true
  245. # @!attribute created_before
  246. # Only include items created before this timestamp (inclusive). This is a query
  247. # parameter used to select responses.
  248. #
  249. # @return [Integer, nil]
  250. 1 optional :created_before, Integer, nil?: true
  251. # @!attribute instructions_search
  252. # Optional string to search the 'instructions' field. This is a query parameter
  253. # used to select responses.
  254. #
  255. # @return [String, nil]
  256. 1 optional :instructions_search, String, nil?: true
  257. # @!attribute metadata
  258. # Metadata filter for the responses. This is a query parameter used to select
  259. # responses.
  260. #
  261. # @return [Object, nil]
  262. 1 optional :metadata, OpenAI::Internal::Type::Unknown, nil?: true
  263. # @!attribute model
  264. # The name of the model to find responses for. This is a query parameter used to
  265. # select responses.
  266. #
  267. # @return [String, nil]
  268. 1 optional :model, String, nil?: true
  269. # @!attribute reasoning_effort
  270. # Optional reasoning effort parameter. This is a query parameter used to select
  271. # responses.
  272. #
  273. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  274. 1 optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  275. # @!attribute temperature
  276. # Sampling temperature. This is a query parameter used to select responses.
  277. #
  278. # @return [Float, nil]
  279. 1 optional :temperature, Float, nil?: true
  280. # @!attribute tools
  281. # List of tool names. This is a query parameter used to select responses.
  282. #
  283. # @return [Array<String>, nil]
  284. 1 optional :tools, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  285. # @!attribute top_p
  286. # Nucleus sampling parameter. This is a query parameter used to select responses.
  287. #
  288. # @return [Float, nil]
  289. 1 optional :top_p, Float, nil?: true
  290. # @!attribute users
  291. # List of user identifiers. This is a query parameter used to select responses.
  292. #
  293. # @return [Array<String>, nil]
  294. 1 optional :users, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  295. # @!method initialize(created_after: nil, created_before: nil, instructions_search: nil, metadata: nil, model: nil, reasoning_effort: nil, temperature: nil, tools: nil, top_p: nil, users: nil, type: :responses)
  296. # Some parameter documentations has been truncated, see
  297. # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::Responses}
  298. # for more details.
  299. #
  300. # A EvalResponsesSource object describing a run data source configuration.
  301. #
  302. # @param created_after [Integer, nil] Only include items created after this timestamp (inclusive). This is a query par
  303. #
  304. # @param created_before [Integer, nil] Only include items created before this timestamp (inclusive). This is a query pa
  305. #
  306. # @param instructions_search [String, nil] Optional string to search the 'instructions' field. This is a query parameter us
  307. #
  308. # @param metadata [Object, nil] Metadata filter for the responses. This is a query parameter used to select resp
  309. #
  310. # @param model [String, nil] The name of the model to find responses for. This is a query parameter used to s
  311. #
  312. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] Optional reasoning effort parameter. This is a query parameter used to select re
  313. #
  314. # @param temperature [Float, nil] Sampling temperature. This is a query parameter used to select responses.
  315. #
  316. # @param tools [Array<String>, nil] List of tool names. This is a query parameter used to select responses.
  317. #
  318. # @param top_p [Float, nil] Nucleus sampling parameter. This is a query parameter used to select responses.
  319. #
  320. # @param users [Array<String>, nil] List of user identifiers. This is a query parameter used to select responses.
  321. #
  322. # @param type [Symbol, :responses] The type of run data source. Always `responses`.
  323. end
  324. # @!method self.variants
  325. # @return [Array(OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::Source::Responses)]
  326. end
  327. # Used when sampling from a model. Dictates the structure of the messages passed
  328. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  329. # `item.input_trajectory`), or a template with variable references to the `item`
  330. # namespace.
  331. #
  332. # @see OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses#input_messages
  333. 1 module InputMessages
  334. 1 extend OpenAI::Internal::Type::Union
  335. 1 discriminator :type
  336. 1 variant :template,
  337. -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template }
  338. 1 variant :item_reference,
  339. -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::ItemReference }
  340. 1 class Template < OpenAI::Internal::Type::BaseModel
  341. # @!attribute template
  342. # A list of chat messages forming the prompt or context. May include variable
  343. # references to the `item` namespace, ie {{item.name}}.
  344. #
  345. # @return [Array<OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem>]
  346. 1 required :template,
  347. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template] }
  348. # @!attribute type
  349. # The type of input messages. Always `template`.
  350. #
  351. # @return [Symbol, :template]
  352. 1 required :type, const: :template
  353. # @!method initialize(template:, type: :template)
  354. # Some parameter documentations has been truncated, see
  355. # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template}
  356. # for more details.
  357. #
  358. # @param template [Array<OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem>] A list of chat messages forming the prompt or context. May include variable refe
  359. #
  360. # @param type [Symbol, :template] The type of input messages. Always `template`.
  361. # A message input to the model with a role indicating instruction following
  362. # hierarchy. Instructions given with the `developer` or `system` role take
  363. # precedence over instructions given with the `user` role. Messages with the
  364. # `assistant` role are presumed to have been generated by the model in previous
  365. # interactions.
  366. 1 module Template
  367. 1 extend OpenAI::Internal::Type::Union
  368. 1 variant -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage }
  369. # A message input to the model with a role indicating instruction following
  370. # hierarchy. Instructions given with the `developer` or `system` role take
  371. # precedence over instructions given with the `user` role. Messages with the
  372. # `assistant` role are presumed to have been generated by the model in previous
  373. # interactions.
  374. 1 variant -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem }
  375. 1 class ChatMessage < OpenAI::Internal::Type::BaseModel
  376. # @!attribute content
  377. # The content of the message.
  378. #
  379. # @return [String]
  380. 1 required :content, String
  381. # @!attribute role
  382. # The role of the message (e.g. "system", "assistant", "user").
  383. #
  384. # @return [String]
  385. 1 required :role, String
  386. # @!method initialize(content:, role:)
  387. # @param content [String] The content of the message.
  388. #
  389. # @param role [String] The role of the message (e.g. "system", "assistant", "user").
  390. end
  391. 1 class EvalItem < OpenAI::Internal::Type::BaseModel
  392. # @!attribute content
  393. # Inputs to the model - can contain template strings.
  394. #
  395. # @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>]
  396. 1 required :content,
  397. union: -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content }
  398. # @!attribute role
  399. # The role of the message input. One of `user`, `assistant`, `system`, or
  400. # `developer`.
  401. #
  402. # @return [Symbol, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role]
  403. 1 required :role,
  404. enum: -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role }
  405. # @!attribute type
  406. # The type of the message input. Always `message`.
  407. #
  408. # @return [Symbol, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type, nil]
  409. 1 optional :type,
  410. enum: -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type }
  411. # @!method initialize(content:, role:, type: nil)
  412. # Some parameter documentations has been truncated, see
  413. # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem}
  414. # for more details.
  415. #
  416. # A message input to the model with a role indicating instruction following
  417. # hierarchy. Instructions given with the `developer` or `system` role take
  418. # precedence over instructions given with the `user` role. Messages with the
  419. # `assistant` role are presumed to have been generated by the model in previous
  420. # interactions.
  421. #
  422. # @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>] Inputs to the model - can contain template strings.
  423. #
  424. # @param role [Symbol, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  425. #
  426. # @param type [Symbol, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type] The type of the message input. Always `message`.
  427. # Inputs to the model - can contain template strings.
  428. #
  429. # @see OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#content
  430. 1 module Content
  431. 1 extend OpenAI::Internal::Type::Union
  432. # A text input to the model.
  433. 1 variant String
  434. # A text input to the model.
  435. 1 variant -> { OpenAI::Responses::ResponseInputText }
  436. # A text output from the model.
  437. 1 variant -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText }
  438. # An image input to the model.
  439. 1 variant -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage }
  440. # A list of inputs, each of which may be either an input text or input image object.
  441. 1 variant -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::AnArrayOfInputTextAndInputImageArray }
  442. 1 class OutputText < OpenAI::Internal::Type::BaseModel
  443. # @!attribute text
  444. # The text output from the model.
  445. #
  446. # @return [String]
  447. 1 required :text, String
  448. # @!attribute type
  449. # The type of the output text. Always `output_text`.
  450. #
  451. # @return [Symbol, :output_text]
  452. 1 required :type, const: :output_text
  453. # @!method initialize(text:, type: :output_text)
  454. # Some parameter documentations has been truncated, see
  455. # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText}
  456. # for more details.
  457. #
  458. # A text output from the model.
  459. #
  460. # @param text [String] The text output from the model.
  461. #
  462. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  463. end
  464. 1 class InputImage < OpenAI::Internal::Type::BaseModel
  465. # @!attribute image_url
  466. # The URL of the image input.
  467. #
  468. # @return [String]
  469. 1 required :image_url, String
  470. # @!attribute type
  471. # The type of the image input. Always `input_image`.
  472. #
  473. # @return [Symbol, :input_image]
  474. 1 required :type, const: :input_image
  475. # @!attribute detail
  476. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  477. # `auto`. Defaults to `auto`.
  478. #
  479. # @return [String, nil]
  480. 1 optional :detail, String
  481. # @!method initialize(image_url:, detail: nil, type: :input_image)
  482. # Some parameter documentations has been truncated, see
  483. # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage}
  484. # for more details.
  485. #
  486. # An image input to the model.
  487. #
  488. # @param image_url [String] The URL of the image input.
  489. #
  490. # @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
  491. #
  492. # @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
  493. end
  494. # @!method self.variants
  495. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>)]
  496. # @type [OpenAI::Internal::Type::Converter]
  497. 1 AnArrayOfInputTextAndInputImageArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
  498. end
  499. # The role of the message input. One of `user`, `assistant`, `system`, or
  500. # `developer`.
  501. #
  502. # @see OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#role
  503. 1 module Role
  504. 1 extend OpenAI::Internal::Type::Enum
  505. 1 USER = :user
  506. 1 ASSISTANT = :assistant
  507. 1 SYSTEM = :system
  508. 1 DEVELOPER = :developer
  509. # @!method self.values
  510. # @return [Array<Symbol>]
  511. end
  512. # The type of the message input. Always `message`.
  513. #
  514. # @see OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#type
  515. 1 module Type
  516. 1 extend OpenAI::Internal::Type::Enum
  517. 1 MESSAGE = :message
  518. # @!method self.values
  519. # @return [Array<Symbol>]
  520. end
  521. end
  522. # @!method self.variants
  523. # @return [Array(OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem)]
  524. end
  525. end
  526. 1 class ItemReference < OpenAI::Internal::Type::BaseModel
  527. # @!attribute item_reference
  528. # A reference to a variable in the `item` namespace. Ie, "item.name"
  529. #
  530. # @return [String]
  531. 1 required :item_reference, String
  532. # @!attribute type
  533. # The type of input messages. Always `item_reference`.
  534. #
  535. # @return [Symbol, :item_reference]
  536. 1 required :type, const: :item_reference
  537. # @!method initialize(item_reference:, type: :item_reference)
  538. # @param item_reference [String] A reference to a variable in the `item` namespace. Ie, "item.name"
  539. #
  540. # @param type [Symbol, :item_reference] The type of input messages. Always `item_reference`.
  541. end
  542. # @!method self.variants
  543. # @return [Array(OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::InputMessages::ItemReference)]
  544. end
  545. # @see OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses#sampling_params
  546. 1 class SamplingParams < OpenAI::Internal::Type::BaseModel
  547. # @!attribute max_completion_tokens
  548. # The maximum number of tokens in the generated output.
  549. #
  550. # @return [Integer, nil]
  551. 1 optional :max_completion_tokens, Integer
  552. # @!attribute seed
  553. # A seed value to initialize the randomness, during sampling.
  554. #
  555. # @return [Integer, nil]
  556. 1 optional :seed, Integer
  557. # @!attribute temperature
  558. # A higher temperature increases randomness in the outputs.
  559. #
  560. # @return [Float, nil]
  561. 1 optional :temperature, Float
  562. # @!attribute text
  563. # Configuration options for a text response from the model. Can be plain text or
  564. # structured JSON data. Learn more:
  565. #
  566. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  567. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  568. #
  569. # @return [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text, nil]
  570. 1 optional :text,
  571. -> { OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text }
  572. # @!attribute tools
  573. # An array of tools the model may call while generating a response. You can
  574. # specify which tool to use by setting the `tool_choice` parameter.
  575. #
  576. # The two categories of tools you can provide the model are:
  577. #
  578. # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
  579. # capabilities, like
  580. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  581. # [file search](https://platform.openai.com/docs/guides/tools-file-search).
  582. # Learn more about
  583. # [built-in tools](https://platform.openai.com/docs/guides/tools).
  584. # - **Function calls (custom tools)**: Functions that are defined by you, enabling
  585. # the model to call your own code. Learn more about
  586. # [function calling](https://platform.openai.com/docs/guides/function-calling).
  587. #
  588. # @return [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>, nil]
  589. 1 optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] }
  590. # @!attribute top_p
  591. # An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  592. #
  593. # @return [Float, nil]
  594. 1 optional :top_p, Float
  595. # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil)
  596. # Some parameter documentations has been truncated, see
  597. # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams}
  598. # for more details.
  599. #
  600. # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output.
  601. #
  602. # @param seed [Integer] A seed value to initialize the randomness, during sampling.
  603. #
  604. # @param temperature [Float] A higher temperature increases randomness in the outputs.
  605. #
  606. # @param text [OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text] Configuration options for a text response from the model. Can be plain
  607. #
  608. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  609. #
  610. # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  611. # @see OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams#text
  612. 1 class Text < OpenAI::Internal::Type::BaseModel
  613. # @!attribute format_
  614. # An object specifying the format that the model must output.
  615. #
  616. # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
  617. # ensures the model will match your supplied JSON schema. Learn more in the
  618. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  619. #
  620. # The default format is `{ "type": "text" }` with no additional options.
  621. #
  622. # **Not recommended for gpt-4o and newer models:**
  623. #
  624. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  625. # ensures the message the model generates is valid JSON. Using `json_schema` is
  626. # preferred for models that support it.
  627. #
  628. # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil]
  629. 1 optional :format_,
  630. union: -> {
  631. OpenAI::Responses::ResponseFormatTextConfig
  632. },
  633. api_name: :format
  634. # @!method initialize(format_: nil)
  635. # Some parameter documentations has been truncated, see
  636. # {OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses::SamplingParams::Text}
  637. # for more details.
  638. #
  639. # Configuration options for a text response from the model. Can be plain text or
  640. # structured JSON data. Learn more:
  641. #
  642. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  643. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  644. #
  645. # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  646. end
  647. end
  648. end
  649. # @!method self.variants
  650. # @return [Array(OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCancelResponse::DataSource::Responses)]
  651. end
  652. 1 class PerModelUsage < OpenAI::Internal::Type::BaseModel
  653. # @!attribute cached_tokens
  654. # The number of tokens retrieved from cache.
  655. #
  656. # @return [Integer]
  657. 1 required :cached_tokens, Integer
  658. # @!attribute completion_tokens
  659. # The number of completion tokens generated.
  660. #
  661. # @return [Integer]
  662. 1 required :completion_tokens, Integer
  663. # @!attribute invocation_count
  664. # The number of invocations.
  665. #
  666. # @return [Integer]
  667. 1 required :invocation_count, Integer
  668. # @!attribute model_name
  669. # The name of the model.
  670. #
  671. # @return [String]
  672. 1 required :model_name, String
  673. # @!attribute prompt_tokens
  674. # The number of prompt tokens used.
  675. #
  676. # @return [Integer]
  677. 1 required :prompt_tokens, Integer
  678. # @!attribute total_tokens
  679. # The total number of tokens used.
  680. #
  681. # @return [Integer]
  682. 1 required :total_tokens, Integer
  683. # @!method initialize(cached_tokens:, completion_tokens:, invocation_count:, model_name:, prompt_tokens:, total_tokens:)
  684. # @param cached_tokens [Integer] The number of tokens retrieved from cache.
  685. #
  686. # @param completion_tokens [Integer] The number of completion tokens generated.
  687. #
  688. # @param invocation_count [Integer] The number of invocations.
  689. #
  690. # @param model_name [String] The name of the model.
  691. #
  692. # @param prompt_tokens [Integer] The number of prompt tokens used.
  693. #
  694. # @param total_tokens [Integer] The total number of tokens used.
  695. end
  696. 1 class PerTestingCriteriaResult < OpenAI::Internal::Type::BaseModel
  697. # @!attribute failed
  698. # Number of tests failed for this criteria.
  699. #
  700. # @return [Integer]
  701. 1 required :failed, Integer
  702. # @!attribute passed
  703. # Number of tests passed for this criteria.
  704. #
  705. # @return [Integer]
  706. 1 required :passed, Integer
  707. # @!attribute testing_criteria
  708. # A description of the testing criteria.
  709. #
  710. # @return [String]
  711. 1 required :testing_criteria, String
  712. # @!method initialize(failed:, passed:, testing_criteria:)
  713. # @param failed [Integer] Number of tests failed for this criteria.
  714. #
  715. # @param passed [Integer] Number of tests passed for this criteria.
  716. #
  717. # @param testing_criteria [String] A description of the testing criteria.
  718. end
  719. # @see OpenAI::Models::Evals::RunCancelResponse#result_counts
  720. 1 class ResultCounts < OpenAI::Internal::Type::BaseModel
  721. # @!attribute errored
  722. # Number of output items that resulted in an error.
  723. #
  724. # @return [Integer]
  725. 1 required :errored, Integer
  726. # @!attribute failed
  727. # Number of output items that failed to pass the evaluation.
  728. #
  729. # @return [Integer]
  730. 1 required :failed, Integer
  731. # @!attribute passed
  732. # Number of output items that passed the evaluation.
  733. #
  734. # @return [Integer]
  735. 1 required :passed, Integer
  736. # @!attribute total
  737. # Total number of executed output items.
  738. #
  739. # @return [Integer]
  740. 1 required :total, Integer
  741. # @!method initialize(errored:, failed:, passed:, total:)
  742. # Counters summarizing the outcomes of the evaluation run.
  743. #
  744. # @param errored [Integer] Number of output items that resulted in an error.
  745. #
  746. # @param failed [Integer] Number of output items that failed to pass the evaluation.
  747. #
  748. # @param passed [Integer] Number of output items that passed the evaluation.
  749. #
  750. # @param total [Integer] Total number of executed output items.
  751. end
  752. end
  753. end
  754. end
  755. end

openai-ruby/lib/openai/models/evals/run_create_params.rb

84.0% lines covered

100.0% branches covered

125 relevant lines. 105 lines covered and 20 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#create
  6. 1 class RunCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute data_source
  10. # Details about the run's data source.
  11. #
  12. # @return [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource]
  13. 1 required :data_source, union: -> { OpenAI::Evals::RunCreateParams::DataSource }
  14. # @!attribute metadata
  15. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  16. # for storing additional information about the object in a structured format, and
  17. # querying for objects via API or the dashboard.
  18. #
  19. # Keys are strings with a maximum length of 64 characters. Values are strings with
  20. # a maximum length of 512 characters.
  21. #
  22. # @return [Hash{Symbol=>String}, nil]
  23. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  24. # @!attribute name
  25. # The name of the run.
  26. #
  27. # @return [String, nil]
  28. 1 optional :name, String
  29. # @!method initialize(data_source:, metadata: nil, name: nil, request_options: {})
  30. # Some parameter documentations has been truncated, see
  31. # {OpenAI::Models::Evals::RunCreateParams} for more details.
  32. #
  33. # @param data_source [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource] Details about the run's data source.
  34. #
  35. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  36. #
  37. # @param name [String] The name of the run.
  38. #
  39. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  40. # Details about the run's data source.
  41. 1 module DataSource
  42. 1 extend OpenAI::Internal::Type::Union
  43. # A JsonlRunDataSource object with that specifies a JSONL file that matches the eval
  44. 1 variant -> { OpenAI::Evals::CreateEvalJSONLRunDataSource }
  45. # A CompletionsRunDataSource object describing a model sampling configuration.
  46. 1 variant -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource }
  47. # A ResponsesRunDataSource object describing a model sampling configuration.
  48. 1 variant -> { OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource }
  49. 1 class CreateEvalResponsesRunDataSource < OpenAI::Internal::Type::BaseModel
  50. # @!attribute source
  51. # Determines what populates the `item` namespace in this run's data source.
  52. #
  53. # @return [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileContent, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileID, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::Responses]
  54. 1 required :source,
  55. union: -> {
  56. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source
  57. }
  58. # @!attribute type
  59. # The type of run data source. Always `responses`.
  60. #
  61. # @return [Symbol, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Type]
  62. 1 required :type,
  63. enum: -> {
  64. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Type
  65. }
  66. # @!attribute input_messages
  67. # Used when sampling from a model. Dictates the structure of the messages passed
  68. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  69. # `item.input_trajectory`), or a template with variable references to the `item`
  70. # namespace.
  71. #
  72. # @return [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::ItemReference, nil]
  73. 1 optional :input_messages,
  74. union: -> {
  75. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages
  76. }
  77. # @!attribute model
  78. # The name of the model to use for generating completions (e.g. "o3-mini").
  79. #
  80. # @return [String, nil]
  81. 1 optional :model, String
  82. # @!attribute sampling_params
  83. #
  84. # @return [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams, nil]
  85. 1 optional :sampling_params,
  86. -> {
  87. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams
  88. }
  89. # @!method initialize(source:, type:, input_messages: nil, model: nil, sampling_params: nil)
  90. # Some parameter documentations has been truncated, see
  91. # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource}
  92. # for more details.
  93. #
  94. # A ResponsesRunDataSource object describing a model sampling configuration.
  95. #
  96. # @param source [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileContent, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileID, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::Responses] Determines what populates the `item` namespace in this run's data source.
  97. #
  98. # @param type [Symbol, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Type] The type of run data source. Always `responses`.
  99. #
  100. # @param input_messages [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::ItemReference] Used when sampling from a model. Dictates the structure of the messages passed i
  101. #
  102. # @param model [String] The name of the model to use for generating completions (e.g. "o3-mini").
  103. #
  104. # @param sampling_params [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams]
  105. # Determines what populates the `item` namespace in this run's data source.
  106. #
  107. # @see OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource#source
  108. 1 module Source
  109. 1 extend OpenAI::Internal::Type::Union
  110. 1 discriminator :type
  111. 1 variant :file_content,
  112. -> {
  113. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileContent
  114. }
  115. 1 variant :file_id,
  116. -> {
  117. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileID
  118. }
  119. # A EvalResponsesSource object describing a run data source configuration.
  120. 1 variant :responses,
  121. -> {
  122. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::Responses
  123. }
  124. 1 class FileContent < OpenAI::Internal::Type::BaseModel
  125. # @!attribute content
  126. # The content of the jsonl file.
  127. #
  128. # @return [Array<OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileContent::Content>]
  129. 1 required :content,
  130. -> {
  131. OpenAI::Internal::Type::ArrayOf[OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileContent::Content]
  132. }
  133. # @!attribute type
  134. # The type of jsonl source. Always `file_content`.
  135. #
  136. # @return [Symbol, :file_content]
  137. 1 required :type, const: :file_content
  138. # @!method initialize(content:, type: :file_content)
  139. # @param content [Array<OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileContent::Content>] The content of the jsonl file.
  140. #
  141. # @param type [Symbol, :file_content] The type of jsonl source. Always `file_content`.
  142. 1 class Content < OpenAI::Internal::Type::BaseModel
  143. # @!attribute item
  144. #
  145. # @return [Hash{Symbol=>Object}]
  146. 1 required :item, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  147. # @!attribute sample
  148. #
  149. # @return [Hash{Symbol=>Object}, nil]
  150. 1 optional :sample, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  151. # @!method initialize(item:, sample: nil)
  152. # @param item [Hash{Symbol=>Object}]
  153. # @param sample [Hash{Symbol=>Object}]
  154. end
  155. end
  156. 1 class FileID < OpenAI::Internal::Type::BaseModel
  157. # @!attribute id
  158. # The identifier of the file.
  159. #
  160. # @return [String]
  161. 1 required :id, String
  162. # @!attribute type
  163. # The type of jsonl source. Always `file_id`.
  164. #
  165. # @return [Symbol, :file_id]
  166. 1 required :type, const: :file_id
  167. # @!method initialize(id:, type: :file_id)
  168. # @param id [String] The identifier of the file.
  169. #
  170. # @param type [Symbol, :file_id] The type of jsonl source. Always `file_id`.
  171. end
  172. 1 class Responses < OpenAI::Internal::Type::BaseModel
  173. # @!attribute type
  174. # The type of run data source. Always `responses`.
  175. #
  176. # @return [Symbol, :responses]
  177. 1 required :type, const: :responses
  178. # @!attribute created_after
  179. # Only include items created after this timestamp (inclusive). This is a query
  180. # parameter used to select responses.
  181. #
  182. # @return [Integer, nil]
  183. 1 optional :created_after, Integer, nil?: true
  184. # @!attribute created_before
  185. # Only include items created before this timestamp (inclusive). This is a query
  186. # parameter used to select responses.
  187. #
  188. # @return [Integer, nil]
  189. 1 optional :created_before, Integer, nil?: true
  190. # @!attribute instructions_search
  191. # Optional string to search the 'instructions' field. This is a query parameter
  192. # used to select responses.
  193. #
  194. # @return [String, nil]
  195. 1 optional :instructions_search, String, nil?: true
  196. # @!attribute metadata
  197. # Metadata filter for the responses. This is a query parameter used to select
  198. # responses.
  199. #
  200. # @return [Object, nil]
  201. 1 optional :metadata, OpenAI::Internal::Type::Unknown, nil?: true
  202. # @!attribute model
  203. # The name of the model to find responses for. This is a query parameter used to
  204. # select responses.
  205. #
  206. # @return [String, nil]
  207. 1 optional :model, String, nil?: true
  208. # @!attribute reasoning_effort
  209. # Optional reasoning effort parameter. This is a query parameter used to select
  210. # responses.
  211. #
  212. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  213. 1 optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  214. # @!attribute temperature
  215. # Sampling temperature. This is a query parameter used to select responses.
  216. #
  217. # @return [Float, nil]
  218. 1 optional :temperature, Float, nil?: true
  219. # @!attribute tools
  220. # List of tool names. This is a query parameter used to select responses.
  221. #
  222. # @return [Array<String>, nil]
  223. 1 optional :tools, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  224. # @!attribute top_p
  225. # Nucleus sampling parameter. This is a query parameter used to select responses.
  226. #
  227. # @return [Float, nil]
  228. 1 optional :top_p, Float, nil?: true
  229. # @!attribute users
  230. # List of user identifiers. This is a query parameter used to select responses.
  231. #
  232. # @return [Array<String>, nil]
  233. 1 optional :users, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  234. # @!method initialize(created_after: nil, created_before: nil, instructions_search: nil, metadata: nil, model: nil, reasoning_effort: nil, temperature: nil, tools: nil, top_p: nil, users: nil, type: :responses)
  235. # Some parameter documentations has been truncated, see
  236. # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::Responses}
  237. # for more details.
  238. #
  239. # A EvalResponsesSource object describing a run data source configuration.
  240. #
  241. # @param created_after [Integer, nil] Only include items created after this timestamp (inclusive). This is a query par
  242. #
  243. # @param created_before [Integer, nil] Only include items created before this timestamp (inclusive). This is a query pa
  244. #
  245. # @param instructions_search [String, nil] Optional string to search the 'instructions' field. This is a query parameter us
  246. #
  247. # @param metadata [Object, nil] Metadata filter for the responses. This is a query parameter used to select resp
  248. #
  249. # @param model [String, nil] The name of the model to find responses for. This is a query parameter used to s
  250. #
  251. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] Optional reasoning effort parameter. This is a query parameter used to select re
  252. #
  253. # @param temperature [Float, nil] Sampling temperature. This is a query parameter used to select responses.
  254. #
  255. # @param tools [Array<String>, nil] List of tool names. This is a query parameter used to select responses.
  256. #
  257. # @param top_p [Float, nil] Nucleus sampling parameter. This is a query parameter used to select responses.
  258. #
  259. # @param users [Array<String>, nil] List of user identifiers. This is a query parameter used to select responses.
  260. #
  261. # @param type [Symbol, :responses] The type of run data source. Always `responses`.
  262. end
  263. # @!method self.variants
  264. # @return [Array(OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileContent, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::FileID, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::Source::Responses)]
  265. end
  266. # The type of run data source. Always `responses`.
  267. #
  268. # @see OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource#type
  269. 1 module Type
  270. 1 extend OpenAI::Internal::Type::Enum
  271. 1 RESPONSES = :responses
  272. # @!method self.values
  273. # @return [Array<Symbol>]
  274. end
  275. # Used when sampling from a model. Dictates the structure of the messages passed
  276. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  277. # `item.input_trajectory`), or a template with variable references to the `item`
  278. # namespace.
  279. #
  280. # @see OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource#input_messages
  281. 1 module InputMessages
  282. 1 extend OpenAI::Internal::Type::Union
  283. 1 discriminator :type
  284. 1 variant :template,
  285. -> {
  286. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template
  287. }
  288. 1 variant :item_reference,
  289. -> {
  290. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::ItemReference
  291. }
  292. 1 class Template < OpenAI::Internal::Type::BaseModel
  293. # @!attribute template
  294. # A list of chat messages forming the prompt or context. May include variable
  295. # references to the `item` namespace, ie {{item.name}}.
  296. #
  297. # @return [Array<OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem>]
  298. 1 required :template,
  299. -> do
  300. OpenAI::Internal::Type::ArrayOf[
  301. union: OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template
  302. ]
  303. end
  304. # @!attribute type
  305. # The type of input messages. Always `template`.
  306. #
  307. # @return [Symbol, :template]
  308. 1 required :type, const: :template
  309. # @!method initialize(template:, type: :template)
  310. # Some parameter documentations has been truncated, see
  311. # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template}
  312. # for more details.
  313. #
  314. # @param template [Array<OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem>] A list of chat messages forming the prompt or context. May include variable refe
  315. #
  316. # @param type [Symbol, :template] The type of input messages. Always `template`.
  317. # A message input to the model with a role indicating instruction following
  318. # hierarchy. Instructions given with the `developer` or `system` role take
  319. # precedence over instructions given with the `user` role. Messages with the
  320. # `assistant` role are presumed to have been generated by the model in previous
  321. # interactions.
  322. 1 module Template
  323. 1 extend OpenAI::Internal::Type::Union
  324. 1 variant -> {
  325. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::ChatMessage
  326. }
  327. # A message input to the model with a role indicating instruction following
  328. # hierarchy. Instructions given with the `developer` or `system` role take
  329. # precedence over instructions given with the `user` role. Messages with the
  330. # `assistant` role are presumed to have been generated by the model in previous
  331. # interactions.
  332. 1 variant -> {
  333. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem
  334. }
  335. 1 class ChatMessage < OpenAI::Internal::Type::BaseModel
  336. # @!attribute content
  337. # The content of the message.
  338. #
  339. # @return [String]
  340. 1 required :content, String
  341. # @!attribute role
  342. # The role of the message (e.g. "system", "assistant", "user").
  343. #
  344. # @return [String]
  345. 1 required :role, String
  346. # @!method initialize(content:, role:)
  347. # @param content [String] The content of the message.
  348. #
  349. # @param role [String] The role of the message (e.g. "system", "assistant", "user").
  350. end
  351. 1 class EvalItem < OpenAI::Internal::Type::BaseModel
  352. # @!attribute content
  353. # Inputs to the model - can contain template strings.
  354. #
  355. # @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>]
  356. 1 required :content,
  357. union: -> {
  358. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content
  359. }
  360. # @!attribute role
  361. # The role of the message input. One of `user`, `assistant`, `system`, or
  362. # `developer`.
  363. #
  364. # @return [Symbol, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Role]
  365. 1 required :role,
  366. enum: -> {
  367. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Role
  368. }
  369. # @!attribute type
  370. # The type of the message input. Always `message`.
  371. #
  372. # @return [Symbol, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Type, nil]
  373. 1 optional :type,
  374. enum: -> {
  375. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Type
  376. }
  377. # @!method initialize(content:, role:, type: nil)
  378. # Some parameter documentations has been truncated, see
  379. # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem}
  380. # for more details.
  381. #
  382. # A message input to the model with a role indicating instruction following
  383. # hierarchy. Instructions given with the `developer` or `system` role take
  384. # precedence over instructions given with the `user` role. Messages with the
  385. # `assistant` role are presumed to have been generated by the model in previous
  386. # interactions.
  387. #
  388. # @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>] Inputs to the model - can contain template strings.
  389. #
  390. # @param role [Symbol, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  391. #
  392. # @param type [Symbol, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Type] The type of the message input. Always `message`.
  393. # Inputs to the model - can contain template strings.
  394. #
  395. # @see OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem#content
  396. 1 module Content
  397. 1 extend OpenAI::Internal::Type::Union
  398. # A text input to the model.
  399. 1 variant String
  400. # A text input to the model.
  401. 1 variant -> { OpenAI::Responses::ResponseInputText }
  402. # A text output from the model.
  403. 1 variant -> {
  404. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::OutputText
  405. }
  406. # An image input to the model.
  407. 1 variant -> {
  408. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::InputImage
  409. }
  410. # A list of inputs, each of which may be either an input text or input image object.
  411. 1 variant -> { OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::AnArrayOfInputTextAndInputImageArray }
  412. 1 class OutputText < OpenAI::Internal::Type::BaseModel
  413. # @!attribute text
  414. # The text output from the model.
  415. #
  416. # @return [String]
  417. 1 required :text, String
  418. # @!attribute type
  419. # The type of the output text. Always `output_text`.
  420. #
  421. # @return [Symbol, :output_text]
  422. 1 required :type, const: :output_text
  423. # @!method initialize(text:, type: :output_text)
  424. # Some parameter documentations has been truncated, see
  425. # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::OutputText}
  426. # for more details.
  427. #
  428. # A text output from the model.
  429. #
  430. # @param text [String] The text output from the model.
  431. #
  432. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  433. end
  434. 1 class InputImage < OpenAI::Internal::Type::BaseModel
  435. # @!attribute image_url
  436. # The URL of the image input.
  437. #
  438. # @return [String]
  439. 1 required :image_url, String
  440. # @!attribute type
  441. # The type of the image input. Always `input_image`.
  442. #
  443. # @return [Symbol, :input_image]
  444. 1 required :type, const: :input_image
  445. # @!attribute detail
  446. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  447. # `auto`. Defaults to `auto`.
  448. #
  449. # @return [String, nil]
  450. 1 optional :detail, String
  451. # @!method initialize(image_url:, detail: nil, type: :input_image)
  452. # Some parameter documentations has been truncated, see
  453. # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::InputImage}
  454. # for more details.
  455. #
  456. # An image input to the model.
  457. #
  458. # @param image_url [String] The URL of the image input.
  459. #
  460. # @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
  461. #
  462. # @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
  463. end
  464. # @!method self.variants
  465. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>)]
  466. # @type [OpenAI::Internal::Type::Converter]
  467. 1 AnArrayOfInputTextAndInputImageArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
  468. end
  469. # The role of the message input. One of `user`, `assistant`, `system`, or
  470. # `developer`.
  471. #
  472. # @see OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem#role
  473. 1 module Role
  474. 1 extend OpenAI::Internal::Type::Enum
  475. 1 USER = :user
  476. 1 ASSISTANT = :assistant
  477. 1 SYSTEM = :system
  478. 1 DEVELOPER = :developer
  479. # @!method self.values
  480. # @return [Array<Symbol>]
  481. end
  482. # The type of the message input. Always `message`.
  483. #
  484. # @see OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem#type
  485. 1 module Type
  486. 1 extend OpenAI::Internal::Type::Enum
  487. 1 MESSAGE = :message
  488. # @!method self.values
  489. # @return [Array<Symbol>]
  490. end
  491. end
  492. # @!method self.variants
  493. # @return [Array(OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template::Template::EvalItem)]
  494. end
  495. end
  496. 1 class ItemReference < OpenAI::Internal::Type::BaseModel
  497. # @!attribute item_reference
  498. # A reference to a variable in the `item` namespace. Ie, "item.name"
  499. #
  500. # @return [String]
  501. 1 required :item_reference, String
  502. # @!attribute type
  503. # The type of input messages. Always `item_reference`.
  504. #
  505. # @return [Symbol, :item_reference]
  506. 1 required :type, const: :item_reference
  507. # @!method initialize(item_reference:, type: :item_reference)
  508. # @param item_reference [String] A reference to a variable in the `item` namespace. Ie, "item.name"
  509. #
  510. # @param type [Symbol, :item_reference] The type of input messages. Always `item_reference`.
  511. end
  512. # @!method self.variants
  513. # @return [Array(OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::Template, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::InputMessages::ItemReference)]
  514. end
  515. # @see OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource#sampling_params
  516. 1 class SamplingParams < OpenAI::Internal::Type::BaseModel
  517. # @!attribute max_completion_tokens
  518. # The maximum number of tokens in the generated output.
  519. #
  520. # @return [Integer, nil]
  521. 1 optional :max_completion_tokens, Integer
  522. # @!attribute seed
  523. # A seed value to initialize the randomness, during sampling.
  524. #
  525. # @return [Integer, nil]
  526. 1 optional :seed, Integer
  527. # @!attribute temperature
  528. # A higher temperature increases randomness in the outputs.
  529. #
  530. # @return [Float, nil]
  531. 1 optional :temperature, Float
  532. # @!attribute text
  533. # Configuration options for a text response from the model. Can be plain text or
  534. # structured JSON data. Learn more:
  535. #
  536. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  537. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  538. #
  539. # @return [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text, nil]
  540. 1 optional :text,
  541. -> {
  542. OpenAI::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text
  543. }
  544. # @!attribute tools
  545. # An array of tools the model may call while generating a response. You can
  546. # specify which tool to use by setting the `tool_choice` parameter.
  547. #
  548. # The two categories of tools you can provide the model are:
  549. #
  550. # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
  551. # capabilities, like
  552. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  553. # [file search](https://platform.openai.com/docs/guides/tools-file-search).
  554. # Learn more about
  555. # [built-in tools](https://platform.openai.com/docs/guides/tools).
  556. # - **Function calls (custom tools)**: Functions that are defined by you, enabling
  557. # the model to call your own code. Learn more about
  558. # [function calling](https://platform.openai.com/docs/guides/function-calling).
  559. #
  560. # @return [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>, nil]
  561. 1 optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] }
  562. # @!attribute top_p
  563. # An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  564. #
  565. # @return [Float, nil]
  566. 1 optional :top_p, Float
  567. # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil)
  568. # Some parameter documentations has been truncated, see
  569. # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams}
  570. # for more details.
  571. #
  572. # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output.
  573. #
  574. # @param seed [Integer] A seed value to initialize the randomness, during sampling.
  575. #
  576. # @param temperature [Float] A higher temperature increases randomness in the outputs.
  577. #
  578. # @param text [OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text] Configuration options for a text response from the model. Can be plain
  579. #
  580. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  581. #
  582. # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  583. # @see OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams#text
  584. 1 class Text < OpenAI::Internal::Type::BaseModel
  585. # @!attribute format_
  586. # An object specifying the format that the model must output.
  587. #
  588. # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
  589. # ensures the model will match your supplied JSON schema. Learn more in the
  590. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  591. #
  592. # The default format is `{ "type": "text" }` with no additional options.
  593. #
  594. # **Not recommended for gpt-4o and newer models:**
  595. #
  596. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  597. # ensures the message the model generates is valid JSON. Using `json_schema` is
  598. # preferred for models that support it.
  599. #
  600. # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil]
  601. 1 optional :format_,
  602. union: -> {
  603. OpenAI::Responses::ResponseFormatTextConfig
  604. },
  605. api_name: :format
  606. # @!method initialize(format_: nil)
  607. # Some parameter documentations has been truncated, see
  608. # {OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource::SamplingParams::Text}
  609. # for more details.
  610. #
  611. # Configuration options for a text response from the model. Can be plain text or
  612. # structured JSON data. Learn more:
  613. #
  614. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  615. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  616. #
  617. # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  618. end
  619. end
  620. end
  621. # @!method self.variants
  622. # @return [Array(OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource)]
  623. end
  624. end
  625. end
  626. end
  627. end

openai-ruby/lib/openai/models/evals/run_create_response.rb

89.51% lines covered

100.0% branches covered

143 relevant lines. 128 lines covered and 15 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#create
  6. 1 class RunCreateResponse < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # Unique identifier for the evaluation run.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # Unix timestamp (in seconds) when the evaluation run was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute data_source
  18. # Information about the run's data source.
  19. #
  20. # @return [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses]
  21. 1 required :data_source, union: -> { OpenAI::Models::Evals::RunCreateResponse::DataSource }
  22. # @!attribute error
  23. # An object representing an error response from the Eval API.
  24. #
  25. # @return [OpenAI::Models::Evals::EvalAPIError]
  26. 1 required :error, -> { OpenAI::Evals::EvalAPIError }
  27. # @!attribute eval_id
  28. # The identifier of the associated evaluation.
  29. #
  30. # @return [String]
  31. 1 required :eval_id, String
  32. # @!attribute metadata
  33. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  34. # for storing additional information about the object in a structured format, and
  35. # querying for objects via API or the dashboard.
  36. #
  37. # Keys are strings with a maximum length of 64 characters. Values are strings with
  38. # a maximum length of 512 characters.
  39. #
  40. # @return [Hash{Symbol=>String}, nil]
  41. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  42. # @!attribute model
  43. # The model that is evaluated, if applicable.
  44. #
  45. # @return [String]
  46. 1 required :model, String
  47. # @!attribute name
  48. # The name of the evaluation run.
  49. #
  50. # @return [String]
  51. 1 required :name, String
  52. # @!attribute object
  53. # The type of the object. Always "eval.run".
  54. #
  55. # @return [Symbol, :"eval.run"]
  56. 1 required :object, const: :"eval.run"
  57. # @!attribute per_model_usage
  58. # Usage statistics for each model during the evaluation run.
  59. #
  60. # @return [Array<OpenAI::Models::Evals::RunCreateResponse::PerModelUsage>]
  61. 1 required :per_model_usage,
  62. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunCreateResponse::PerModelUsage] }
  63. # @!attribute per_testing_criteria_results
  64. # Results per testing criteria applied during the evaluation run.
  65. #
  66. # @return [Array<OpenAI::Models::Evals::RunCreateResponse::PerTestingCriteriaResult>]
  67. 1 required :per_testing_criteria_results,
  68. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunCreateResponse::PerTestingCriteriaResult] }
  69. # @!attribute report_url
  70. # The URL to the rendered evaluation run report on the UI dashboard.
  71. #
  72. # @return [String]
  73. 1 required :report_url, String
  74. # @!attribute result_counts
  75. # Counters summarizing the outcomes of the evaluation run.
  76. #
  77. # @return [OpenAI::Models::Evals::RunCreateResponse::ResultCounts]
  78. 1 required :result_counts, -> { OpenAI::Models::Evals::RunCreateResponse::ResultCounts }
  79. # @!attribute status
  80. # The status of the evaluation run.
  81. #
  82. # @return [String]
  83. 1 required :status, String
  84. # @!method initialize(id:, created_at:, data_source:, error:, eval_id:, metadata:, model:, name:, per_model_usage:, per_testing_criteria_results:, report_url:, result_counts:, status:, object: :"eval.run")
  85. # Some parameter documentations has been truncated, see
  86. # {OpenAI::Models::Evals::RunCreateResponse} for more details.
  87. #
  88. # A schema representing an evaluation run.
  89. #
  90. # @param id [String] Unique identifier for the evaluation run.
  91. #
  92. # @param created_at [Integer] Unix timestamp (in seconds) when the evaluation run was created.
  93. #
  94. # @param data_source [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses] Information about the run's data source.
  95. #
  96. # @param error [OpenAI::Models::Evals::EvalAPIError] An object representing an error response from the Eval API.
  97. #
  98. # @param eval_id [String] The identifier of the associated evaluation.
  99. #
  100. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  101. #
  102. # @param model [String] The model that is evaluated, if applicable.
  103. #
  104. # @param name [String] The name of the evaluation run.
  105. #
  106. # @param per_model_usage [Array<OpenAI::Models::Evals::RunCreateResponse::PerModelUsage>] Usage statistics for each model during the evaluation run.
  107. #
  108. # @param per_testing_criteria_results [Array<OpenAI::Models::Evals::RunCreateResponse::PerTestingCriteriaResult>] Results per testing criteria applied during the evaluation run.
  109. #
  110. # @param report_url [String] The URL to the rendered evaluation run report on the UI dashboard.
  111. #
  112. # @param result_counts [OpenAI::Models::Evals::RunCreateResponse::ResultCounts] Counters summarizing the outcomes of the evaluation run.
  113. #
  114. # @param status [String] The status of the evaluation run.
  115. #
  116. # @param object [Symbol, :"eval.run"] The type of the object. Always "eval.run".
  117. # Information about the run's data source.
  118. #
  119. # @see OpenAI::Models::Evals::RunCreateResponse#data_source
  120. 1 module DataSource
  121. 1 extend OpenAI::Internal::Type::Union
  122. 1 discriminator :type
  123. # A JsonlRunDataSource object with that specifies a JSONL file that matches the eval
  124. 1 variant :jsonl, -> { OpenAI::Evals::CreateEvalJSONLRunDataSource }
  125. # A CompletionsRunDataSource object describing a model sampling configuration.
  126. 1 variant :completions, -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource }
  127. # A ResponsesRunDataSource object describing a model sampling configuration.
  128. 1 variant :responses, -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses }
  129. 1 class Responses < OpenAI::Internal::Type::BaseModel
  130. # @!attribute source
  131. # Determines what populates the `item` namespace in this run's data source.
  132. #
  133. # @return [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::Responses]
  134. 1 required :source, union: -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source }
  135. # @!attribute type
  136. # The type of run data source. Always `responses`.
  137. #
  138. # @return [Symbol, :responses]
  139. 1 required :type, const: :responses
  140. # @!attribute input_messages
  141. # Used when sampling from a model. Dictates the structure of the messages passed
  142. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  143. # `item.input_trajectory`), or a template with variable references to the `item`
  144. # namespace.
  145. #
  146. # @return [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::ItemReference, nil]
  147. 1 optional :input_messages,
  148. union: -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages }
  149. # @!attribute model
  150. # The name of the model to use for generating completions (e.g. "o3-mini").
  151. #
  152. # @return [String, nil]
  153. 1 optional :model, String
  154. # @!attribute sampling_params
  155. #
  156. # @return [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams, nil]
  157. 1 optional :sampling_params,
  158. -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams }
  159. # @!method initialize(source:, input_messages: nil, model: nil, sampling_params: nil, type: :responses)
  160. # Some parameter documentations has been truncated, see
  161. # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses} for more
  162. # details.
  163. #
  164. # A ResponsesRunDataSource object describing a model sampling configuration.
  165. #
  166. # @param source [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::Responses] Determines what populates the `item` namespace in this run's data source.
  167. #
  168. # @param input_messages [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::ItemReference] Used when sampling from a model. Dictates the structure of the messages passed i
  169. #
  170. # @param model [String] The name of the model to use for generating completions (e.g. "o3-mini").
  171. #
  172. # @param sampling_params [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams]
  173. #
  174. # @param type [Symbol, :responses] The type of run data source. Always `responses`.
  175. # Determines what populates the `item` namespace in this run's data source.
  176. #
  177. # @see OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses#source
  178. 1 module Source
  179. 1 extend OpenAI::Internal::Type::Union
  180. 1 discriminator :type
  181. 1 variant :file_content,
  182. -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileContent }
  183. 1 variant :file_id, -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileID }
  184. # A EvalResponsesSource object describing a run data source configuration.
  185. 1 variant :responses,
  186. -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::Responses }
  187. 1 class FileContent < OpenAI::Internal::Type::BaseModel
  188. # @!attribute content
  189. # The content of the jsonl file.
  190. #
  191. # @return [Array<OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileContent::Content>]
  192. 1 required :content,
  193. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileContent::Content] }
  194. # @!attribute type
  195. # The type of jsonl source. Always `file_content`.
  196. #
  197. # @return [Symbol, :file_content]
  198. 1 required :type, const: :file_content
  199. # @!method initialize(content:, type: :file_content)
  200. # @param content [Array<OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileContent::Content>] The content of the jsonl file.
  201. #
  202. # @param type [Symbol, :file_content] The type of jsonl source. Always `file_content`.
  203. 1 class Content < OpenAI::Internal::Type::BaseModel
  204. # @!attribute item
  205. #
  206. # @return [Hash{Symbol=>Object}]
  207. 1 required :item, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  208. # @!attribute sample
  209. #
  210. # @return [Hash{Symbol=>Object}, nil]
  211. 1 optional :sample, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  212. # @!method initialize(item:, sample: nil)
  213. # @param item [Hash{Symbol=>Object}]
  214. # @param sample [Hash{Symbol=>Object}]
  215. end
  216. end
  217. 1 class FileID < OpenAI::Internal::Type::BaseModel
  218. # @!attribute id
  219. # The identifier of the file.
  220. #
  221. # @return [String]
  222. 1 required :id, String
  223. # @!attribute type
  224. # The type of jsonl source. Always `file_id`.
  225. #
  226. # @return [Symbol, :file_id]
  227. 1 required :type, const: :file_id
  228. # @!method initialize(id:, type: :file_id)
  229. # @param id [String] The identifier of the file.
  230. #
  231. # @param type [Symbol, :file_id] The type of jsonl source. Always `file_id`.
  232. end
  233. 1 class Responses < OpenAI::Internal::Type::BaseModel
  234. # @!attribute type
  235. # The type of run data source. Always `responses`.
  236. #
  237. # @return [Symbol, :responses]
  238. 1 required :type, const: :responses
  239. # @!attribute created_after
  240. # Only include items created after this timestamp (inclusive). This is a query
  241. # parameter used to select responses.
  242. #
  243. # @return [Integer, nil]
  244. 1 optional :created_after, Integer, nil?: true
  245. # @!attribute created_before
  246. # Only include items created before this timestamp (inclusive). This is a query
  247. # parameter used to select responses.
  248. #
  249. # @return [Integer, nil]
  250. 1 optional :created_before, Integer, nil?: true
  251. # @!attribute instructions_search
  252. # Optional string to search the 'instructions' field. This is a query parameter
  253. # used to select responses.
  254. #
  255. # @return [String, nil]
  256. 1 optional :instructions_search, String, nil?: true
  257. # @!attribute metadata
  258. # Metadata filter for the responses. This is a query parameter used to select
  259. # responses.
  260. #
  261. # @return [Object, nil]
  262. 1 optional :metadata, OpenAI::Internal::Type::Unknown, nil?: true
  263. # @!attribute model
  264. # The name of the model to find responses for. This is a query parameter used to
  265. # select responses.
  266. #
  267. # @return [String, nil]
  268. 1 optional :model, String, nil?: true
  269. # @!attribute reasoning_effort
  270. # Optional reasoning effort parameter. This is a query parameter used to select
  271. # responses.
  272. #
  273. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  274. 1 optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  275. # @!attribute temperature
  276. # Sampling temperature. This is a query parameter used to select responses.
  277. #
  278. # @return [Float, nil]
  279. 1 optional :temperature, Float, nil?: true
  280. # @!attribute tools
  281. # List of tool names. This is a query parameter used to select responses.
  282. #
  283. # @return [Array<String>, nil]
  284. 1 optional :tools, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  285. # @!attribute top_p
  286. # Nucleus sampling parameter. This is a query parameter used to select responses.
  287. #
  288. # @return [Float, nil]
  289. 1 optional :top_p, Float, nil?: true
  290. # @!attribute users
  291. # List of user identifiers. This is a query parameter used to select responses.
  292. #
  293. # @return [Array<String>, nil]
  294. 1 optional :users, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  295. # @!method initialize(created_after: nil, created_before: nil, instructions_search: nil, metadata: nil, model: nil, reasoning_effort: nil, temperature: nil, tools: nil, top_p: nil, users: nil, type: :responses)
  296. # Some parameter documentations has been truncated, see
  297. # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::Responses}
  298. # for more details.
  299. #
  300. # A EvalResponsesSource object describing a run data source configuration.
  301. #
  302. # @param created_after [Integer, nil] Only include items created after this timestamp (inclusive). This is a query par
  303. #
  304. # @param created_before [Integer, nil] Only include items created before this timestamp (inclusive). This is a query pa
  305. #
  306. # @param instructions_search [String, nil] Optional string to search the 'instructions' field. This is a query parameter us
  307. #
  308. # @param metadata [Object, nil] Metadata filter for the responses. This is a query parameter used to select resp
  309. #
  310. # @param model [String, nil] The name of the model to find responses for. This is a query parameter used to s
  311. #
  312. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] Optional reasoning effort parameter. This is a query parameter used to select re
  313. #
  314. # @param temperature [Float, nil] Sampling temperature. This is a query parameter used to select responses.
  315. #
  316. # @param tools [Array<String>, nil] List of tool names. This is a query parameter used to select responses.
  317. #
  318. # @param top_p [Float, nil] Nucleus sampling parameter. This is a query parameter used to select responses.
  319. #
  320. # @param users [Array<String>, nil] List of user identifiers. This is a query parameter used to select responses.
  321. #
  322. # @param type [Symbol, :responses] The type of run data source. Always `responses`.
  323. end
  324. # @!method self.variants
  325. # @return [Array(OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::Source::Responses)]
  326. end
  327. # Used when sampling from a model. Dictates the structure of the messages passed
  328. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  329. # `item.input_trajectory`), or a template with variable references to the `item`
  330. # namespace.
  331. #
  332. # @see OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses#input_messages
  333. 1 module InputMessages
  334. 1 extend OpenAI::Internal::Type::Union
  335. 1 discriminator :type
  336. 1 variant :template,
  337. -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template }
  338. 1 variant :item_reference,
  339. -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::ItemReference }
  340. 1 class Template < OpenAI::Internal::Type::BaseModel
  341. # @!attribute template
  342. # A list of chat messages forming the prompt or context. May include variable
  343. # references to the `item` namespace, ie {{item.name}}.
  344. #
  345. # @return [Array<OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem>]
  346. 1 required :template,
  347. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template] }
  348. # @!attribute type
  349. # The type of input messages. Always `template`.
  350. #
  351. # @return [Symbol, :template]
  352. 1 required :type, const: :template
  353. # @!method initialize(template:, type: :template)
  354. # Some parameter documentations has been truncated, see
  355. # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template}
  356. # for more details.
  357. #
  358. # @param template [Array<OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem>] A list of chat messages forming the prompt or context. May include variable refe
  359. #
  360. # @param type [Symbol, :template] The type of input messages. Always `template`.
  361. # A message input to the model with a role indicating instruction following
  362. # hierarchy. Instructions given with the `developer` or `system` role take
  363. # precedence over instructions given with the `user` role. Messages with the
  364. # `assistant` role are presumed to have been generated by the model in previous
  365. # interactions.
  366. 1 module Template
  367. 1 extend OpenAI::Internal::Type::Union
  368. 1 variant -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage }
  369. # A message input to the model with a role indicating instruction following
  370. # hierarchy. Instructions given with the `developer` or `system` role take
  371. # precedence over instructions given with the `user` role. Messages with the
  372. # `assistant` role are presumed to have been generated by the model in previous
  373. # interactions.
  374. 1 variant -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem }
  375. 1 class ChatMessage < OpenAI::Internal::Type::BaseModel
  376. # @!attribute content
  377. # The content of the message.
  378. #
  379. # @return [String]
  380. 1 required :content, String
  381. # @!attribute role
  382. # The role of the message (e.g. "system", "assistant", "user").
  383. #
  384. # @return [String]
  385. 1 required :role, String
  386. # @!method initialize(content:, role:)
  387. # @param content [String] The content of the message.
  388. #
  389. # @param role [String] The role of the message (e.g. "system", "assistant", "user").
  390. end
  391. 1 class EvalItem < OpenAI::Internal::Type::BaseModel
  392. # @!attribute content
  393. # Inputs to the model - can contain template strings.
  394. #
  395. # @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>]
  396. 1 required :content,
  397. union: -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content }
  398. # @!attribute role
  399. # The role of the message input. One of `user`, `assistant`, `system`, or
  400. # `developer`.
  401. #
  402. # @return [Symbol, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role]
  403. 1 required :role,
  404. enum: -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role }
  405. # @!attribute type
  406. # The type of the message input. Always `message`.
  407. #
  408. # @return [Symbol, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type, nil]
  409. 1 optional :type,
  410. enum: -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type }
  411. # @!method initialize(content:, role:, type: nil)
  412. # Some parameter documentations has been truncated, see
  413. # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem}
  414. # for more details.
  415. #
  416. # A message input to the model with a role indicating instruction following
  417. # hierarchy. Instructions given with the `developer` or `system` role take
  418. # precedence over instructions given with the `user` role. Messages with the
  419. # `assistant` role are presumed to have been generated by the model in previous
  420. # interactions.
  421. #
  422. # @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>] Inputs to the model - can contain template strings.
  423. #
  424. # @param role [Symbol, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  425. #
  426. # @param type [Symbol, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type] The type of the message input. Always `message`.
  427. # Inputs to the model - can contain template strings.
  428. #
  429. # @see OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#content
  430. 1 module Content
  431. 1 extend OpenAI::Internal::Type::Union
  432. # A text input to the model.
  433. 1 variant String
  434. # A text input to the model.
  435. 1 variant -> { OpenAI::Responses::ResponseInputText }
  436. # A text output from the model.
  437. 1 variant -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText }
  438. # An image input to the model.
  439. 1 variant -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage }
  440. # A list of inputs, each of which may be either an input text or input image object.
  441. 1 variant -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::AnArrayOfInputTextAndInputImageArray }
  442. 1 class OutputText < OpenAI::Internal::Type::BaseModel
  443. # @!attribute text
  444. # The text output from the model.
  445. #
  446. # @return [String]
  447. 1 required :text, String
  448. # @!attribute type
  449. # The type of the output text. Always `output_text`.
  450. #
  451. # @return [Symbol, :output_text]
  452. 1 required :type, const: :output_text
  453. # @!method initialize(text:, type: :output_text)
  454. # Some parameter documentations has been truncated, see
  455. # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText}
  456. # for more details.
  457. #
  458. # A text output from the model.
  459. #
  460. # @param text [String] The text output from the model.
  461. #
  462. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  463. end
  464. 1 class InputImage < OpenAI::Internal::Type::BaseModel
  465. # @!attribute image_url
  466. # The URL of the image input.
  467. #
  468. # @return [String]
  469. 1 required :image_url, String
  470. # @!attribute type
  471. # The type of the image input. Always `input_image`.
  472. #
  473. # @return [Symbol, :input_image]
  474. 1 required :type, const: :input_image
  475. # @!attribute detail
  476. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  477. # `auto`. Defaults to `auto`.
  478. #
  479. # @return [String, nil]
  480. 1 optional :detail, String
  481. # @!method initialize(image_url:, detail: nil, type: :input_image)
  482. # Some parameter documentations has been truncated, see
  483. # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage}
  484. # for more details.
  485. #
  486. # An image input to the model.
  487. #
  488. # @param image_url [String] The URL of the image input.
  489. #
  490. # @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
  491. #
  492. # @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
  493. end
  494. # @!method self.variants
  495. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>)]
  496. # @type [OpenAI::Internal::Type::Converter]
  497. 1 AnArrayOfInputTextAndInputImageArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
  498. end
  499. # The role of the message input. One of `user`, `assistant`, `system`, or
  500. # `developer`.
  501. #
  502. # @see OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#role
  503. 1 module Role
  504. 1 extend OpenAI::Internal::Type::Enum
  505. 1 USER = :user
  506. 1 ASSISTANT = :assistant
  507. 1 SYSTEM = :system
  508. 1 DEVELOPER = :developer
  509. # @!method self.values
  510. # @return [Array<Symbol>]
  511. end
  512. # The type of the message input. Always `message`.
  513. #
  514. # @see OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#type
  515. 1 module Type
  516. 1 extend OpenAI::Internal::Type::Enum
  517. 1 MESSAGE = :message
  518. # @!method self.values
  519. # @return [Array<Symbol>]
  520. end
  521. end
  522. # @!method self.variants
  523. # @return [Array(OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem)]
  524. end
  525. end
  526. 1 class ItemReference < OpenAI::Internal::Type::BaseModel
  527. # @!attribute item_reference
  528. # A reference to a variable in the `item` namespace. Ie, "item.name"
  529. #
  530. # @return [String]
  531. 1 required :item_reference, String
  532. # @!attribute type
  533. # The type of input messages. Always `item_reference`.
  534. #
  535. # @return [Symbol, :item_reference]
  536. 1 required :type, const: :item_reference
  537. # @!method initialize(item_reference:, type: :item_reference)
  538. # @param item_reference [String] A reference to a variable in the `item` namespace. Ie, "item.name"
  539. #
  540. # @param type [Symbol, :item_reference] The type of input messages. Always `item_reference`.
  541. end
  542. # @!method self.variants
  543. # @return [Array(OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::InputMessages::ItemReference)]
  544. end
  545. # @see OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses#sampling_params
  546. 1 class SamplingParams < OpenAI::Internal::Type::BaseModel
  547. # @!attribute max_completion_tokens
  548. # The maximum number of tokens in the generated output.
  549. #
  550. # @return [Integer, nil]
  551. 1 optional :max_completion_tokens, Integer
  552. # @!attribute seed
  553. # A seed value to initialize the randomness, during sampling.
  554. #
  555. # @return [Integer, nil]
  556. 1 optional :seed, Integer
  557. # @!attribute temperature
  558. # A higher temperature increases randomness in the outputs.
  559. #
  560. # @return [Float, nil]
  561. 1 optional :temperature, Float
  562. # @!attribute text
  563. # Configuration options for a text response from the model. Can be plain text or
  564. # structured JSON data. Learn more:
  565. #
  566. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  567. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  568. #
  569. # @return [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text, nil]
  570. 1 optional :text,
  571. -> { OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text }
  572. # @!attribute tools
  573. # An array of tools the model may call while generating a response. You can
  574. # specify which tool to use by setting the `tool_choice` parameter.
  575. #
  576. # The two categories of tools you can provide the model are:
  577. #
  578. # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
  579. # capabilities, like
  580. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  581. # [file search](https://platform.openai.com/docs/guides/tools-file-search).
  582. # Learn more about
  583. # [built-in tools](https://platform.openai.com/docs/guides/tools).
  584. # - **Function calls (custom tools)**: Functions that are defined by you, enabling
  585. # the model to call your own code. Learn more about
  586. # [function calling](https://platform.openai.com/docs/guides/function-calling).
  587. #
  588. # @return [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>, nil]
  589. 1 optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] }
  590. # @!attribute top_p
  591. # An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  592. #
  593. # @return [Float, nil]
  594. 1 optional :top_p, Float
  595. # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil)
  596. # Some parameter documentations has been truncated, see
  597. # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams}
  598. # for more details.
  599. #
  600. # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output.
  601. #
  602. # @param seed [Integer] A seed value to initialize the randomness, during sampling.
  603. #
  604. # @param temperature [Float] A higher temperature increases randomness in the outputs.
  605. #
  606. # @param text [OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text] Configuration options for a text response from the model. Can be plain
  607. #
  608. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  609. #
  610. # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  611. # @see OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams#text
  612. 1 class Text < OpenAI::Internal::Type::BaseModel
  613. # @!attribute format_
  614. # An object specifying the format that the model must output.
  615. #
  616. # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
  617. # ensures the model will match your supplied JSON schema. Learn more in the
  618. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  619. #
  620. # The default format is `{ "type": "text" }` with no additional options.
  621. #
  622. # **Not recommended for gpt-4o and newer models:**
  623. #
  624. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  625. # ensures the message the model generates is valid JSON. Using `json_schema` is
  626. # preferred for models that support it.
  627. #
  628. # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil]
  629. 1 optional :format_,
  630. union: -> {
  631. OpenAI::Responses::ResponseFormatTextConfig
  632. },
  633. api_name: :format
  634. # @!method initialize(format_: nil)
  635. # Some parameter documentations has been truncated, see
  636. # {OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses::SamplingParams::Text}
  637. # for more details.
  638. #
  639. # Configuration options for a text response from the model. Can be plain text or
  640. # structured JSON data. Learn more:
  641. #
  642. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  643. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  644. #
  645. # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  646. end
  647. end
  648. end
  649. # @!method self.variants
  650. # @return [Array(OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCreateResponse::DataSource::Responses)]
  651. end
  652. 1 class PerModelUsage < OpenAI::Internal::Type::BaseModel
  653. # @!attribute cached_tokens
  654. # The number of tokens retrieved from cache.
  655. #
  656. # @return [Integer]
  657. 1 required :cached_tokens, Integer
  658. # @!attribute completion_tokens
  659. # The number of completion tokens generated.
  660. #
  661. # @return [Integer]
  662. 1 required :completion_tokens, Integer
  663. # @!attribute invocation_count
  664. # The number of invocations.
  665. #
  666. # @return [Integer]
  667. 1 required :invocation_count, Integer
  668. # @!attribute model_name
  669. # The name of the model.
  670. #
  671. # @return [String]
  672. 1 required :model_name, String
  673. # @!attribute prompt_tokens
  674. # The number of prompt tokens used.
  675. #
  676. # @return [Integer]
  677. 1 required :prompt_tokens, Integer
  678. # @!attribute total_tokens
  679. # The total number of tokens used.
  680. #
  681. # @return [Integer]
  682. 1 required :total_tokens, Integer
  683. # @!method initialize(cached_tokens:, completion_tokens:, invocation_count:, model_name:, prompt_tokens:, total_tokens:)
  684. # @param cached_tokens [Integer] The number of tokens retrieved from cache.
  685. #
  686. # @param completion_tokens [Integer] The number of completion tokens generated.
  687. #
  688. # @param invocation_count [Integer] The number of invocations.
  689. #
  690. # @param model_name [String] The name of the model.
  691. #
  692. # @param prompt_tokens [Integer] The number of prompt tokens used.
  693. #
  694. # @param total_tokens [Integer] The total number of tokens used.
  695. end
  696. 1 class PerTestingCriteriaResult < OpenAI::Internal::Type::BaseModel
  697. # @!attribute failed
  698. # Number of tests failed for this criteria.
  699. #
  700. # @return [Integer]
  701. 1 required :failed, Integer
  702. # @!attribute passed
  703. # Number of tests passed for this criteria.
  704. #
  705. # @return [Integer]
  706. 1 required :passed, Integer
  707. # @!attribute testing_criteria
  708. # A description of the testing criteria.
  709. #
  710. # @return [String]
  711. 1 required :testing_criteria, String
  712. # @!method initialize(failed:, passed:, testing_criteria:)
  713. # @param failed [Integer] Number of tests failed for this criteria.
  714. #
  715. # @param passed [Integer] Number of tests passed for this criteria.
  716. #
  717. # @param testing_criteria [String] A description of the testing criteria.
  718. end
  719. # @see OpenAI::Models::Evals::RunCreateResponse#result_counts
  720. 1 class ResultCounts < OpenAI::Internal::Type::BaseModel
  721. # @!attribute errored
  722. # Number of output items that resulted in an error.
  723. #
  724. # @return [Integer]
  725. 1 required :errored, Integer
  726. # @!attribute failed
  727. # Number of output items that failed to pass the evaluation.
  728. #
  729. # @return [Integer]
  730. 1 required :failed, Integer
  731. # @!attribute passed
  732. # Number of output items that passed the evaluation.
  733. #
  734. # @return [Integer]
  735. 1 required :passed, Integer
  736. # @!attribute total
  737. # Total number of executed output items.
  738. #
  739. # @return [Integer]
  740. 1 required :total, Integer
  741. # @!method initialize(errored:, failed:, passed:, total:)
  742. # Counters summarizing the outcomes of the evaluation run.
  743. #
  744. # @param errored [Integer] Number of output items that resulted in an error.
  745. #
  746. # @param failed [Integer] Number of output items that failed to pass the evaluation.
  747. #
  748. # @param passed [Integer] Number of output items that passed the evaluation.
  749. #
  750. # @param total [Integer] Total number of executed output items.
  751. end
  752. end
  753. end
  754. end
  755. end

openai-ruby/lib/openai/models/evals/run_delete_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#delete
  6. 1 class RunDeleteParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute eval_id
  10. #
  11. # @return [String]
  12. 1 required :eval_id, String
  13. # @!method initialize(eval_id:, request_options: {})
  14. # @param eval_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/evals/run_delete_response.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#delete
  6. 1 class RunDeleteResponse < OpenAI::Internal::Type::BaseModel
  7. # @!attribute deleted
  8. #
  9. # @return [Boolean, nil]
  10. 1 optional :deleted, OpenAI::Internal::Type::Boolean
  11. # @!attribute object
  12. #
  13. # @return [String, nil]
  14. 1 optional :object, String
  15. # @!attribute run_id
  16. #
  17. # @return [String, nil]
  18. 1 optional :run_id, String
  19. # @!method initialize(deleted: nil, object: nil, run_id: nil)
  20. # @param deleted [Boolean]
  21. # @param object [String]
  22. # @param run_id [String]
  23. end
  24. end
  25. end
  26. end

openai-ruby/lib/openai/models/evals/run_list_params.rb

100.0% lines covered

100.0% branches covered

21 relevant lines. 21 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#list
  6. 1 class RunListParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute after
  10. # Identifier for the last run from the previous pagination request.
  11. #
  12. # @return [String, nil]
  13. 1 optional :after, String
  14. # @!attribute limit
  15. # Number of runs to retrieve.
  16. #
  17. # @return [Integer, nil]
  18. 1 optional :limit, Integer
  19. # @!attribute order
  20. # Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for
  21. # descending order. Defaults to `asc`.
  22. #
  23. # @return [Symbol, OpenAI::Models::Evals::RunListParams::Order, nil]
  24. 1 optional :order, enum: -> { OpenAI::Evals::RunListParams::Order }
  25. # @!attribute status
  26. # Filter runs by status. One of `queued` | `in_progress` | `failed` | `completed`
  27. # | `canceled`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Evals::RunListParams::Status, nil]
  30. 1 optional :status, enum: -> { OpenAI::Evals::RunListParams::Status }
  31. # @!method initialize(after: nil, limit: nil, order: nil, status: nil, request_options: {})
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Evals::RunListParams} for more details.
  34. #
  35. # @param after [String] Identifier for the last run from the previous pagination request.
  36. #
  37. # @param limit [Integer] Number of runs to retrieve.
  38. #
  39. # @param order [Symbol, OpenAI::Models::Evals::RunListParams::Order] Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for de
  40. #
  41. # @param status [Symbol, OpenAI::Models::Evals::RunListParams::Status] Filter runs by status. One of `queued` | `in_progress` | `failed` | `completed`
  42. #
  43. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  44. # Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for
  45. # descending order. Defaults to `asc`.
  46. 1 module Order
  47. 1 extend OpenAI::Internal::Type::Enum
  48. 1 ASC = :asc
  49. 1 DESC = :desc
  50. # @!method self.values
  51. # @return [Array<Symbol>]
  52. end
  53. # Filter runs by status. One of `queued` | `in_progress` | `failed` | `completed`
  54. # | `canceled`.
  55. 1 module Status
  56. 1 extend OpenAI::Internal::Type::Enum
  57. 1 QUEUED = :queued
  58. 1 IN_PROGRESS = :in_progress
  59. 1 COMPLETED = :completed
  60. 1 CANCELED = :canceled
  61. 1 FAILED = :failed
  62. # @!method self.values
  63. # @return [Array<Symbol>]
  64. end
  65. end
  66. end
  67. end
  68. end

openai-ruby/lib/openai/models/evals/run_list_response.rb

90.14% lines covered

100.0% branches covered

142 relevant lines. 128 lines covered and 14 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#list
  6. 1 class RunListResponse < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # Unique identifier for the evaluation run.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # Unix timestamp (in seconds) when the evaluation run was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute data_source
  18. # Information about the run's data source.
  19. #
  20. # @return [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunListResponse::DataSource::Responses]
  21. 1 required :data_source, union: -> { OpenAI::Models::Evals::RunListResponse::DataSource }
  22. # @!attribute error
  23. # An object representing an error response from the Eval API.
  24. #
  25. # @return [OpenAI::Models::Evals::EvalAPIError]
  26. 1 required :error, -> { OpenAI::Evals::EvalAPIError }
  27. # @!attribute eval_id
  28. # The identifier of the associated evaluation.
  29. #
  30. # @return [String]
  31. 1 required :eval_id, String
  32. # @!attribute metadata
  33. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  34. # for storing additional information about the object in a structured format, and
  35. # querying for objects via API or the dashboard.
  36. #
  37. # Keys are strings with a maximum length of 64 characters. Values are strings with
  38. # a maximum length of 512 characters.
  39. #
  40. # @return [Hash{Symbol=>String}, nil]
  41. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  42. # @!attribute model
  43. # The model that is evaluated, if applicable.
  44. #
  45. # @return [String]
  46. 1 required :model, String
  47. # @!attribute name
  48. # The name of the evaluation run.
  49. #
  50. # @return [String]
  51. 1 required :name, String
  52. # @!attribute object
  53. # The type of the object. Always "eval.run".
  54. #
  55. # @return [Symbol, :"eval.run"]
  56. 1 required :object, const: :"eval.run"
  57. # @!attribute per_model_usage
  58. # Usage statistics for each model during the evaluation run.
  59. #
  60. # @return [Array<OpenAI::Models::Evals::RunListResponse::PerModelUsage>]
  61. 1 required :per_model_usage,
  62. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunListResponse::PerModelUsage] }
  63. # @!attribute per_testing_criteria_results
  64. # Results per testing criteria applied during the evaluation run.
  65. #
  66. # @return [Array<OpenAI::Models::Evals::RunListResponse::PerTestingCriteriaResult>]
  67. 1 required :per_testing_criteria_results,
  68. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunListResponse::PerTestingCriteriaResult] }
  69. # @!attribute report_url
  70. # The URL to the rendered evaluation run report on the UI dashboard.
  71. #
  72. # @return [String]
  73. 1 required :report_url, String
  74. # @!attribute result_counts
  75. # Counters summarizing the outcomes of the evaluation run.
  76. #
  77. # @return [OpenAI::Models::Evals::RunListResponse::ResultCounts]
  78. 1 required :result_counts, -> { OpenAI::Models::Evals::RunListResponse::ResultCounts }
  79. # @!attribute status
  80. # The status of the evaluation run.
  81. #
  82. # @return [String]
  83. 1 required :status, String
  84. # @!method initialize(id:, created_at:, data_source:, error:, eval_id:, metadata:, model:, name:, per_model_usage:, per_testing_criteria_results:, report_url:, result_counts:, status:, object: :"eval.run")
  85. # Some parameter documentations has been truncated, see
  86. # {OpenAI::Models::Evals::RunListResponse} for more details.
  87. #
  88. # A schema representing an evaluation run.
  89. #
  90. # @param id [String] Unique identifier for the evaluation run.
  91. #
  92. # @param created_at [Integer] Unix timestamp (in seconds) when the evaluation run was created.
  93. #
  94. # @param data_source [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunListResponse::DataSource::Responses] Information about the run's data source.
  95. #
  96. # @param error [OpenAI::Models::Evals::EvalAPIError] An object representing an error response from the Eval API.
  97. #
  98. # @param eval_id [String] The identifier of the associated evaluation.
  99. #
  100. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  101. #
  102. # @param model [String] The model that is evaluated, if applicable.
  103. #
  104. # @param name [String] The name of the evaluation run.
  105. #
  106. # @param per_model_usage [Array<OpenAI::Models::Evals::RunListResponse::PerModelUsage>] Usage statistics for each model during the evaluation run.
  107. #
  108. # @param per_testing_criteria_results [Array<OpenAI::Models::Evals::RunListResponse::PerTestingCriteriaResult>] Results per testing criteria applied during the evaluation run.
  109. #
  110. # @param report_url [String] The URL to the rendered evaluation run report on the UI dashboard.
  111. #
  112. # @param result_counts [OpenAI::Models::Evals::RunListResponse::ResultCounts] Counters summarizing the outcomes of the evaluation run.
  113. #
  114. # @param status [String] The status of the evaluation run.
  115. #
  116. # @param object [Symbol, :"eval.run"] The type of the object. Always "eval.run".
  117. # Information about the run's data source.
  118. #
  119. # @see OpenAI::Models::Evals::RunListResponse#data_source
  120. 1 module DataSource
  121. 1 extend OpenAI::Internal::Type::Union
  122. 1 discriminator :type
  123. # A JsonlRunDataSource object with that specifies a JSONL file that matches the eval
  124. 1 variant :jsonl, -> { OpenAI::Evals::CreateEvalJSONLRunDataSource }
  125. # A CompletionsRunDataSource object describing a model sampling configuration.
  126. 1 variant :completions, -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource }
  127. # A ResponsesRunDataSource object describing a model sampling configuration.
  128. 1 variant :responses, -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses }
  129. 1 class Responses < OpenAI::Internal::Type::BaseModel
  130. # @!attribute source
  131. # Determines what populates the `item` namespace in this run's data source.
  132. #
  133. # @return [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::Responses]
  134. 1 required :source, union: -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source }
  135. # @!attribute type
  136. # The type of run data source. Always `responses`.
  137. #
  138. # @return [Symbol, :responses]
  139. 1 required :type, const: :responses
  140. # @!attribute input_messages
  141. # Used when sampling from a model. Dictates the structure of the messages passed
  142. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  143. # `item.input_trajectory`), or a template with variable references to the `item`
  144. # namespace.
  145. #
  146. # @return [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::ItemReference, nil]
  147. 1 optional :input_messages,
  148. union: -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages }
  149. # @!attribute model
  150. # The name of the model to use for generating completions (e.g. "o3-mini").
  151. #
  152. # @return [String, nil]
  153. 1 optional :model, String
  154. # @!attribute sampling_params
  155. #
  156. # @return [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams, nil]
  157. 1 optional :sampling_params,
  158. -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams }
  159. # @!method initialize(source:, input_messages: nil, model: nil, sampling_params: nil, type: :responses)
  160. # Some parameter documentations has been truncated, see
  161. # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses} for more
  162. # details.
  163. #
  164. # A ResponsesRunDataSource object describing a model sampling configuration.
  165. #
  166. # @param source [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::Responses] Determines what populates the `item` namespace in this run's data source.
  167. #
  168. # @param input_messages [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::ItemReference] Used when sampling from a model. Dictates the structure of the messages passed i
  169. #
  170. # @param model [String] The name of the model to use for generating completions (e.g. "o3-mini").
  171. #
  172. # @param sampling_params [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams]
  173. #
  174. # @param type [Symbol, :responses] The type of run data source. Always `responses`.
  175. # Determines what populates the `item` namespace in this run's data source.
  176. #
  177. # @see OpenAI::Models::Evals::RunListResponse::DataSource::Responses#source
  178. 1 module Source
  179. 1 extend OpenAI::Internal::Type::Union
  180. 1 discriminator :type
  181. 1 variant :file_content,
  182. -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileContent }
  183. 1 variant :file_id, -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileID }
  184. # A EvalResponsesSource object describing a run data source configuration.
  185. 1 variant :responses,
  186. -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::Responses }
  187. 1 class FileContent < OpenAI::Internal::Type::BaseModel
  188. # @!attribute content
  189. # The content of the jsonl file.
  190. #
  191. # @return [Array<OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileContent::Content>]
  192. 1 required :content,
  193. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileContent::Content] }
  194. # @!attribute type
  195. # The type of jsonl source. Always `file_content`.
  196. #
  197. # @return [Symbol, :file_content]
  198. 1 required :type, const: :file_content
  199. # @!method initialize(content:, type: :file_content)
  200. # @param content [Array<OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileContent::Content>] The content of the jsonl file.
  201. #
  202. # @param type [Symbol, :file_content] The type of jsonl source. Always `file_content`.
  203. 1 class Content < OpenAI::Internal::Type::BaseModel
  204. # @!attribute item
  205. #
  206. # @return [Hash{Symbol=>Object}]
  207. 1 required :item, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  208. # @!attribute sample
  209. #
  210. # @return [Hash{Symbol=>Object}, nil]
  211. 1 optional :sample, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  212. # @!method initialize(item:, sample: nil)
  213. # @param item [Hash{Symbol=>Object}]
  214. # @param sample [Hash{Symbol=>Object}]
  215. end
  216. end
  217. 1 class FileID < OpenAI::Internal::Type::BaseModel
  218. # @!attribute id
  219. # The identifier of the file.
  220. #
  221. # @return [String]
  222. 1 required :id, String
  223. # @!attribute type
  224. # The type of jsonl source. Always `file_id`.
  225. #
  226. # @return [Symbol, :file_id]
  227. 1 required :type, const: :file_id
  228. # @!method initialize(id:, type: :file_id)
  229. # @param id [String] The identifier of the file.
  230. #
  231. # @param type [Symbol, :file_id] The type of jsonl source. Always `file_id`.
  232. end
  233. 1 class Responses < OpenAI::Internal::Type::BaseModel
  234. # @!attribute type
  235. # The type of run data source. Always `responses`.
  236. #
  237. # @return [Symbol, :responses]
  238. 1 required :type, const: :responses
  239. # @!attribute created_after
  240. # Only include items created after this timestamp (inclusive). This is a query
  241. # parameter used to select responses.
  242. #
  243. # @return [Integer, nil]
  244. 1 optional :created_after, Integer, nil?: true
  245. # @!attribute created_before
  246. # Only include items created before this timestamp (inclusive). This is a query
  247. # parameter used to select responses.
  248. #
  249. # @return [Integer, nil]
  250. 1 optional :created_before, Integer, nil?: true
  251. # @!attribute instructions_search
  252. # Optional string to search the 'instructions' field. This is a query parameter
  253. # used to select responses.
  254. #
  255. # @return [String, nil]
  256. 1 optional :instructions_search, String, nil?: true
  257. # @!attribute metadata
  258. # Metadata filter for the responses. This is a query parameter used to select
  259. # responses.
  260. #
  261. # @return [Object, nil]
  262. 1 optional :metadata, OpenAI::Internal::Type::Unknown, nil?: true
  263. # @!attribute model
  264. # The name of the model to find responses for. This is a query parameter used to
  265. # select responses.
  266. #
  267. # @return [String, nil]
  268. 1 optional :model, String, nil?: true
  269. # @!attribute reasoning_effort
  270. # Optional reasoning effort parameter. This is a query parameter used to select
  271. # responses.
  272. #
  273. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  274. 1 optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  275. # @!attribute temperature
  276. # Sampling temperature. This is a query parameter used to select responses.
  277. #
  278. # @return [Float, nil]
  279. 1 optional :temperature, Float, nil?: true
  280. # @!attribute tools
  281. # List of tool names. This is a query parameter used to select responses.
  282. #
  283. # @return [Array<String>, nil]
  284. 1 optional :tools, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  285. # @!attribute top_p
  286. # Nucleus sampling parameter. This is a query parameter used to select responses.
  287. #
  288. # @return [Float, nil]
  289. 1 optional :top_p, Float, nil?: true
  290. # @!attribute users
  291. # List of user identifiers. This is a query parameter used to select responses.
  292. #
  293. # @return [Array<String>, nil]
  294. 1 optional :users, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  295. # @!method initialize(created_after: nil, created_before: nil, instructions_search: nil, metadata: nil, model: nil, reasoning_effort: nil, temperature: nil, tools: nil, top_p: nil, users: nil, type: :responses)
  296. # Some parameter documentations has been truncated, see
  297. # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::Responses}
  298. # for more details.
  299. #
  300. # A EvalResponsesSource object describing a run data source configuration.
  301. #
  302. # @param created_after [Integer, nil] Only include items created after this timestamp (inclusive). This is a query par
  303. #
  304. # @param created_before [Integer, nil] Only include items created before this timestamp (inclusive). This is a query pa
  305. #
  306. # @param instructions_search [String, nil] Optional string to search the 'instructions' field. This is a query parameter us
  307. #
  308. # @param metadata [Object, nil] Metadata filter for the responses. This is a query parameter used to select resp
  309. #
  310. # @param model [String, nil] The name of the model to find responses for. This is a query parameter used to s
  311. #
  312. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] Optional reasoning effort parameter. This is a query parameter used to select re
  313. #
  314. # @param temperature [Float, nil] Sampling temperature. This is a query parameter used to select responses.
  315. #
  316. # @param tools [Array<String>, nil] List of tool names. This is a query parameter used to select responses.
  317. #
  318. # @param top_p [Float, nil] Nucleus sampling parameter. This is a query parameter used to select responses.
  319. #
  320. # @param users [Array<String>, nil] List of user identifiers. This is a query parameter used to select responses.
  321. #
  322. # @param type [Symbol, :responses] The type of run data source. Always `responses`.
  323. end
  324. # @!method self.variants
  325. # @return [Array(OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::Source::Responses)]
  326. end
  327. # Used when sampling from a model. Dictates the structure of the messages passed
  328. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  329. # `item.input_trajectory`), or a template with variable references to the `item`
  330. # namespace.
  331. #
  332. # @see OpenAI::Models::Evals::RunListResponse::DataSource::Responses#input_messages
  333. 1 module InputMessages
  334. 1 extend OpenAI::Internal::Type::Union
  335. 1 discriminator :type
  336. 1 variant :template,
  337. -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template }
  338. 1 variant :item_reference,
  339. -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::ItemReference }
  340. 1 class Template < OpenAI::Internal::Type::BaseModel
  341. # @!attribute template
  342. # A list of chat messages forming the prompt or context. May include variable
  343. # references to the `item` namespace, ie {{item.name}}.
  344. #
  345. # @return [Array<OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem>]
  346. 1 required :template,
  347. -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template] }
  348. # @!attribute type
  349. # The type of input messages. Always `template`.
  350. #
  351. # @return [Symbol, :template]
  352. 1 required :type, const: :template
  353. # @!method initialize(template:, type: :template)
  354. # Some parameter documentations has been truncated, see
  355. # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template}
  356. # for more details.
  357. #
  358. # @param template [Array<OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem>] A list of chat messages forming the prompt or context. May include variable refe
  359. #
  360. # @param type [Symbol, :template] The type of input messages. Always `template`.
  361. # A message input to the model with a role indicating instruction following
  362. # hierarchy. Instructions given with the `developer` or `system` role take
  363. # precedence over instructions given with the `user` role. Messages with the
  364. # `assistant` role are presumed to have been generated by the model in previous
  365. # interactions.
  366. 1 module Template
  367. 1 extend OpenAI::Internal::Type::Union
  368. 1 variant -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage }
  369. # A message input to the model with a role indicating instruction following
  370. # hierarchy. Instructions given with the `developer` or `system` role take
  371. # precedence over instructions given with the `user` role. Messages with the
  372. # `assistant` role are presumed to have been generated by the model in previous
  373. # interactions.
  374. 1 variant -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem }
  375. 1 class ChatMessage < OpenAI::Internal::Type::BaseModel
  376. # @!attribute content
  377. # The content of the message.
  378. #
  379. # @return [String]
  380. 1 required :content, String
  381. # @!attribute role
  382. # The role of the message (e.g. "system", "assistant", "user").
  383. #
  384. # @return [String]
  385. 1 required :role, String
  386. # @!method initialize(content:, role:)
  387. # @param content [String] The content of the message.
  388. #
  389. # @param role [String] The role of the message (e.g. "system", "assistant", "user").
  390. end
  391. 1 class EvalItem < OpenAI::Internal::Type::BaseModel
  392. # @!attribute content
  393. # Inputs to the model - can contain template strings.
  394. #
  395. # @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>]
  396. 1 required :content,
  397. union: -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content }
  398. # @!attribute role
  399. # The role of the message input. One of `user`, `assistant`, `system`, or
  400. # `developer`.
  401. #
  402. # @return [Symbol, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role]
  403. 1 required :role,
  404. enum: -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role }
  405. # @!attribute type
  406. # The type of the message input. Always `message`.
  407. #
  408. # @return [Symbol, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type, nil]
  409. 1 optional :type,
  410. enum: -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type }
  411. # @!method initialize(content:, role:, type: nil)
  412. # Some parameter documentations has been truncated, see
  413. # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem}
  414. # for more details.
  415. #
  416. # A message input to the model with a role indicating instruction following
  417. # hierarchy. Instructions given with the `developer` or `system` role take
  418. # precedence over instructions given with the `user` role. Messages with the
  419. # `assistant` role are presumed to have been generated by the model in previous
  420. # interactions.
  421. #
  422. # @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>] Inputs to the model - can contain template strings.
  423. #
  424. # @param role [Symbol, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  425. #
  426. # @param type [Symbol, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type] The type of the message input. Always `message`.
  427. # Inputs to the model - can contain template strings.
  428. #
  429. # @see OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#content
  430. 1 module Content
  431. 1 extend OpenAI::Internal::Type::Union
  432. # A text input to the model.
  433. 1 variant String
  434. # A text input to the model.
  435. 1 variant -> { OpenAI::Responses::ResponseInputText }
  436. # A text output from the model.
  437. 1 variant -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText }
  438. # An image input to the model.
  439. 1 variant -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage }
  440. # A list of inputs, each of which may be either an input text or input image object.
  441. 1 variant -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::AnArrayOfInputTextAndInputImageArray }
  442. 1 class OutputText < OpenAI::Internal::Type::BaseModel
  443. # @!attribute text
  444. # The text output from the model.
  445. #
  446. # @return [String]
  447. 1 required :text, String
  448. # @!attribute type
  449. # The type of the output text. Always `output_text`.
  450. #
  451. # @return [Symbol, :output_text]
  452. 1 required :type, const: :output_text
  453. # @!method initialize(text:, type: :output_text)
  454. # Some parameter documentations has been truncated, see
  455. # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText}
  456. # for more details.
  457. #
  458. # A text output from the model.
  459. #
  460. # @param text [String] The text output from the model.
  461. #
  462. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  463. end
  464. 1 class InputImage < OpenAI::Internal::Type::BaseModel
  465. # @!attribute image_url
  466. # The URL of the image input.
  467. #
  468. # @return [String]
  469. 1 required :image_url, String
  470. # @!attribute type
  471. # The type of the image input. Always `input_image`.
  472. #
  473. # @return [Symbol, :input_image]
  474. 1 required :type, const: :input_image
  475. # @!attribute detail
  476. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  477. # `auto`. Defaults to `auto`.
  478. #
  479. # @return [String, nil]
  480. 1 optional :detail, String
  481. # @!method initialize(image_url:, detail: nil, type: :input_image)
  482. # Some parameter documentations has been truncated, see
  483. # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage}
  484. # for more details.
  485. #
  486. # An image input to the model.
  487. #
  488. # @param image_url [String] The URL of the image input.
  489. #
  490. # @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
  491. #
  492. # @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
  493. end
  494. # @!method self.variants
  495. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>)]
  496. # @type [OpenAI::Internal::Type::Converter]
  497. 1 AnArrayOfInputTextAndInputImageArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
  498. end
  499. # The role of the message input. One of `user`, `assistant`, `system`, or
  500. # `developer`.
  501. #
  502. # @see OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#role
  503. 1 module Role
  504. 1 extend OpenAI::Internal::Type::Enum
  505. 1 USER = :user
  506. 1 ASSISTANT = :assistant
  507. 1 SYSTEM = :system
  508. 1 DEVELOPER = :developer
  509. # @!method self.values
  510. # @return [Array<Symbol>]
  511. end
  512. # The type of the message input. Always `message`.
  513. #
  514. # @see OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#type
  515. 1 module Type
  516. 1 extend OpenAI::Internal::Type::Enum
  517. 1 MESSAGE = :message
  518. # @!method self.values
  519. # @return [Array<Symbol>]
  520. end
  521. end
  522. # @!method self.variants
  523. # @return [Array(OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem)]
  524. end
  525. end
  526. 1 class ItemReference < OpenAI::Internal::Type::BaseModel
  527. # @!attribute item_reference
  528. # A reference to a variable in the `item` namespace. Ie, "item.name"
  529. #
  530. # @return [String]
  531. 1 required :item_reference, String
  532. # @!attribute type
  533. # The type of input messages. Always `item_reference`.
  534. #
  535. # @return [Symbol, :item_reference]
  536. 1 required :type, const: :item_reference
  537. # @!method initialize(item_reference:, type: :item_reference)
  538. # @param item_reference [String] A reference to a variable in the `item` namespace. Ie, "item.name"
  539. #
  540. # @param type [Symbol, :item_reference] The type of input messages. Always `item_reference`.
  541. end
  542. # @!method self.variants
  543. # @return [Array(OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunListResponse::DataSource::Responses::InputMessages::ItemReference)]
  544. end
  545. # @see OpenAI::Models::Evals::RunListResponse::DataSource::Responses#sampling_params
  546. 1 class SamplingParams < OpenAI::Internal::Type::BaseModel
  547. # @!attribute max_completion_tokens
  548. # The maximum number of tokens in the generated output.
  549. #
  550. # @return [Integer, nil]
  551. 1 optional :max_completion_tokens, Integer
  552. # @!attribute seed
  553. # A seed value to initialize the randomness, during sampling.
  554. #
  555. # @return [Integer, nil]
  556. 1 optional :seed, Integer
  557. # @!attribute temperature
  558. # A higher temperature increases randomness in the outputs.
  559. #
  560. # @return [Float, nil]
  561. 1 optional :temperature, Float
  562. # @!attribute text
  563. # Configuration options for a text response from the model. Can be plain text or
  564. # structured JSON data. Learn more:
  565. #
  566. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  567. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  568. #
  569. # @return [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text, nil]
  570. 1 optional :text, -> { OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text }
  571. # @!attribute tools
  572. # An array of tools the model may call while generating a response. You can
  573. # specify which tool to use by setting the `tool_choice` parameter.
  574. #
  575. # The two categories of tools you can provide the model are:
  576. #
  577. # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
  578. # capabilities, like
  579. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  580. # [file search](https://platform.openai.com/docs/guides/tools-file-search).
  581. # Learn more about
  582. # [built-in tools](https://platform.openai.com/docs/guides/tools).
  583. # - **Function calls (custom tools)**: Functions that are defined by you, enabling
  584. # the model to call your own code. Learn more about
  585. # [function calling](https://platform.openai.com/docs/guides/function-calling).
  586. #
  587. # @return [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>, nil]
  588. 1 optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] }
  589. # @!attribute top_p
  590. # An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  591. #
  592. # @return [Float, nil]
  593. 1 optional :top_p, Float
  594. # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil)
  595. # Some parameter documentations has been truncated, see
  596. # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams}
  597. # for more details.
  598. #
  599. # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output.
  600. #
  601. # @param seed [Integer] A seed value to initialize the randomness, during sampling.
  602. #
  603. # @param temperature [Float] A higher temperature increases randomness in the outputs.
  604. #
  605. # @param text [OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text] Configuration options for a text response from the model. Can be plain
  606. #
  607. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  608. #
  609. # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  610. # @see OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams#text
  611. 1 class Text < OpenAI::Internal::Type::BaseModel
  612. # @!attribute format_
  613. # An object specifying the format that the model must output.
  614. #
  615. # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
  616. # ensures the model will match your supplied JSON schema. Learn more in the
  617. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  618. #
  619. # The default format is `{ "type": "text" }` with no additional options.
  620. #
  621. # **Not recommended for gpt-4o and newer models:**
  622. #
  623. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  624. # ensures the message the model generates is valid JSON. Using `json_schema` is
  625. # preferred for models that support it.
  626. #
  627. # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil]
  628. 1 optional :format_,
  629. union: -> {
  630. OpenAI::Responses::ResponseFormatTextConfig
  631. },
  632. api_name: :format
  633. # @!method initialize(format_: nil)
  634. # Some parameter documentations has been truncated, see
  635. # {OpenAI::Models::Evals::RunListResponse::DataSource::Responses::SamplingParams::Text}
  636. # for more details.
  637. #
  638. # Configuration options for a text response from the model. Can be plain text or
  639. # structured JSON data. Learn more:
  640. #
  641. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  642. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  643. #
  644. # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  645. end
  646. end
  647. end
  648. # @!method self.variants
  649. # @return [Array(OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunListResponse::DataSource::Responses)]
  650. end
  651. 1 class PerModelUsage < OpenAI::Internal::Type::BaseModel
  652. # @!attribute cached_tokens
  653. # The number of tokens retrieved from cache.
  654. #
  655. # @return [Integer]
  656. 1 required :cached_tokens, Integer
  657. # @!attribute completion_tokens
  658. # The number of completion tokens generated.
  659. #
  660. # @return [Integer]
  661. 1 required :completion_tokens, Integer
  662. # @!attribute invocation_count
  663. # The number of invocations.
  664. #
  665. # @return [Integer]
  666. 1 required :invocation_count, Integer
  667. # @!attribute model_name
  668. # The name of the model.
  669. #
  670. # @return [String]
  671. 1 required :model_name, String
  672. # @!attribute prompt_tokens
  673. # The number of prompt tokens used.
  674. #
  675. # @return [Integer]
  676. 1 required :prompt_tokens, Integer
  677. # @!attribute total_tokens
  678. # The total number of tokens used.
  679. #
  680. # @return [Integer]
  681. 1 required :total_tokens, Integer
  682. # @!method initialize(cached_tokens:, completion_tokens:, invocation_count:, model_name:, prompt_tokens:, total_tokens:)
  683. # @param cached_tokens [Integer] The number of tokens retrieved from cache.
  684. #
  685. # @param completion_tokens [Integer] The number of completion tokens generated.
  686. #
  687. # @param invocation_count [Integer] The number of invocations.
  688. #
  689. # @param model_name [String] The name of the model.
  690. #
  691. # @param prompt_tokens [Integer] The number of prompt tokens used.
  692. #
  693. # @param total_tokens [Integer] The total number of tokens used.
  694. end
  695. 1 class PerTestingCriteriaResult < OpenAI::Internal::Type::BaseModel
  696. # @!attribute failed
  697. # Number of tests failed for this criteria.
  698. #
  699. # @return [Integer]
  700. 1 required :failed, Integer
  701. # @!attribute passed
  702. # Number of tests passed for this criteria.
  703. #
  704. # @return [Integer]
  705. 1 required :passed, Integer
  706. # @!attribute testing_criteria
  707. # A description of the testing criteria.
  708. #
  709. # @return [String]
  710. 1 required :testing_criteria, String
  711. # @!method initialize(failed:, passed:, testing_criteria:)
  712. # @param failed [Integer] Number of tests failed for this criteria.
  713. #
  714. # @param passed [Integer] Number of tests passed for this criteria.
  715. #
  716. # @param testing_criteria [String] A description of the testing criteria.
  717. end
  718. # @see OpenAI::Models::Evals::RunListResponse#result_counts
  719. 1 class ResultCounts < OpenAI::Internal::Type::BaseModel
  720. # @!attribute errored
  721. # Number of output items that resulted in an error.
  722. #
  723. # @return [Integer]
  724. 1 required :errored, Integer
  725. # @!attribute failed
  726. # Number of output items that failed to pass the evaluation.
  727. #
  728. # @return [Integer]
  729. 1 required :failed, Integer
  730. # @!attribute passed
  731. # Number of output items that passed the evaluation.
  732. #
  733. # @return [Integer]
  734. 1 required :passed, Integer
  735. # @!attribute total
  736. # Total number of executed output items.
  737. #
  738. # @return [Integer]
  739. 1 required :total, Integer
  740. # @!method initialize(errored:, failed:, passed:, total:)
  741. # Counters summarizing the outcomes of the evaluation run.
  742. #
  743. # @param errored [Integer] Number of output items that resulted in an error.
  744. #
  745. # @param failed [Integer] Number of output items that failed to pass the evaluation.
  746. #
  747. # @param passed [Integer] Number of output items that passed the evaluation.
  748. #
  749. # @param total [Integer] Total number of executed output items.
  750. end
  751. end
  752. end
  753. end
  754. end

openai-ruby/lib/openai/models/evals/run_retrieve_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#retrieve
  6. 1 class RunRetrieveParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute eval_id
  10. #
  11. # @return [String]
  12. 1 required :eval_id, String
  13. # @!method initialize(eval_id:, request_options: {})
  14. # @param eval_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/evals/run_retrieve_response.rb

89.51% lines covered

100.0% branches covered

143 relevant lines. 128 lines covered and 15 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. # @see OpenAI::Resources::Evals::Runs#retrieve
  6. 1 class RunRetrieveResponse < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # Unique identifier for the evaluation run.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # Unix timestamp (in seconds) when the evaluation run was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute data_source
  18. # Information about the run's data source.
  19. #
  20. # @return [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses]
  21. 1 required :data_source, union: -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource }
  22. # @!attribute error
  23. # An object representing an error response from the Eval API.
  24. #
  25. # @return [OpenAI::Models::Evals::EvalAPIError]
  26. 1 required :error, -> { OpenAI::Evals::EvalAPIError }
  27. # @!attribute eval_id
  28. # The identifier of the associated evaluation.
  29. #
  30. # @return [String]
  31. 1 required :eval_id, String
  32. # @!attribute metadata
  33. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  34. # for storing additional information about the object in a structured format, and
  35. # querying for objects via API or the dashboard.
  36. #
  37. # Keys are strings with a maximum length of 64 characters. Values are strings with
  38. # a maximum length of 512 characters.
  39. #
  40. # @return [Hash{Symbol=>String}, nil]
  41. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  42. # @!attribute model
  43. # The model that is evaluated, if applicable.
  44. #
  45. # @return [String]
  46. 1 required :model, String
  47. # @!attribute name
  48. # The name of the evaluation run.
  49. #
  50. # @return [String]
  51. 1 required :name, String
  52. # @!attribute object
  53. # The type of the object. Always "eval.run".
  54. #
  55. # @return [Symbol, :"eval.run"]
  56. 1 required :object, const: :"eval.run"
  57. # @!attribute per_model_usage
  58. # Usage statistics for each model during the evaluation run.
  59. #
  60. # @return [Array<OpenAI::Models::Evals::RunRetrieveResponse::PerModelUsage>]
  61. 1 required :per_model_usage,
  62. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunRetrieveResponse::PerModelUsage] }
  63. # @!attribute per_testing_criteria_results
  64. # Results per testing criteria applied during the evaluation run.
  65. #
  66. # @return [Array<OpenAI::Models::Evals::RunRetrieveResponse::PerTestingCriteriaResult>]
  67. 1 required :per_testing_criteria_results,
  68. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunRetrieveResponse::PerTestingCriteriaResult] }
  69. # @!attribute report_url
  70. # The URL to the rendered evaluation run report on the UI dashboard.
  71. #
  72. # @return [String]
  73. 1 required :report_url, String
  74. # @!attribute result_counts
  75. # Counters summarizing the outcomes of the evaluation run.
  76. #
  77. # @return [OpenAI::Models::Evals::RunRetrieveResponse::ResultCounts]
  78. 1 required :result_counts, -> { OpenAI::Models::Evals::RunRetrieveResponse::ResultCounts }
  79. # @!attribute status
  80. # The status of the evaluation run.
  81. #
  82. # @return [String]
  83. 1 required :status, String
  84. # @!method initialize(id:, created_at:, data_source:, error:, eval_id:, metadata:, model:, name:, per_model_usage:, per_testing_criteria_results:, report_url:, result_counts:, status:, object: :"eval.run")
  85. # Some parameter documentations has been truncated, see
  86. # {OpenAI::Models::Evals::RunRetrieveResponse} for more details.
  87. #
  88. # A schema representing an evaluation run.
  89. #
  90. # @param id [String] Unique identifier for the evaluation run.
  91. #
  92. # @param created_at [Integer] Unix timestamp (in seconds) when the evaluation run was created.
  93. #
  94. # @param data_source [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses] Information about the run's data source.
  95. #
  96. # @param error [OpenAI::Models::Evals::EvalAPIError] An object representing an error response from the Eval API.
  97. #
  98. # @param eval_id [String] The identifier of the associated evaluation.
  99. #
  100. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  101. #
  102. # @param model [String] The model that is evaluated, if applicable.
  103. #
  104. # @param name [String] The name of the evaluation run.
  105. #
  106. # @param per_model_usage [Array<OpenAI::Models::Evals::RunRetrieveResponse::PerModelUsage>] Usage statistics for each model during the evaluation run.
  107. #
  108. # @param per_testing_criteria_results [Array<OpenAI::Models::Evals::RunRetrieveResponse::PerTestingCriteriaResult>] Results per testing criteria applied during the evaluation run.
  109. #
  110. # @param report_url [String] The URL to the rendered evaluation run report on the UI dashboard.
  111. #
  112. # @param result_counts [OpenAI::Models::Evals::RunRetrieveResponse::ResultCounts] Counters summarizing the outcomes of the evaluation run.
  113. #
  114. # @param status [String] The status of the evaluation run.
  115. #
  116. # @param object [Symbol, :"eval.run"] The type of the object. Always "eval.run".
  117. # Information about the run's data source.
  118. #
  119. # @see OpenAI::Models::Evals::RunRetrieveResponse#data_source
  120. 1 module DataSource
  121. 1 extend OpenAI::Internal::Type::Union
  122. 1 discriminator :type
  123. # A JsonlRunDataSource object with that specifies a JSONL file that matches the eval
  124. 1 variant :jsonl, -> { OpenAI::Evals::CreateEvalJSONLRunDataSource }
  125. # A CompletionsRunDataSource object describing a model sampling configuration.
  126. 1 variant :completions, -> { OpenAI::Evals::CreateEvalCompletionsRunDataSource }
  127. # A ResponsesRunDataSource object describing a model sampling configuration.
  128. 1 variant :responses, -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses }
  129. 1 class Responses < OpenAI::Internal::Type::BaseModel
  130. # @!attribute source
  131. # Determines what populates the `item` namespace in this run's data source.
  132. #
  133. # @return [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::Responses]
  134. 1 required :source, union: -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source }
  135. # @!attribute type
  136. # The type of run data source. Always `responses`.
  137. #
  138. # @return [Symbol, :responses]
  139. 1 required :type, const: :responses
  140. # @!attribute input_messages
  141. # Used when sampling from a model. Dictates the structure of the messages passed
  142. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  143. # `item.input_trajectory`), or a template with variable references to the `item`
  144. # namespace.
  145. #
  146. # @return [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::ItemReference, nil]
  147. 1 optional :input_messages,
  148. union: -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages }
  149. # @!attribute model
  150. # The name of the model to use for generating completions (e.g. "o3-mini").
  151. #
  152. # @return [String, nil]
  153. 1 optional :model, String
  154. # @!attribute sampling_params
  155. #
  156. # @return [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams, nil]
  157. 1 optional :sampling_params,
  158. -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams }
  159. # @!method initialize(source:, input_messages: nil, model: nil, sampling_params: nil, type: :responses)
  160. # Some parameter documentations has been truncated, see
  161. # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses} for more
  162. # details.
  163. #
  164. # A ResponsesRunDataSource object describing a model sampling configuration.
  165. #
  166. # @param source [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::Responses] Determines what populates the `item` namespace in this run's data source.
  167. #
  168. # @param input_messages [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::ItemReference] Used when sampling from a model. Dictates the structure of the messages passed i
  169. #
  170. # @param model [String] The name of the model to use for generating completions (e.g. "o3-mini").
  171. #
  172. # @param sampling_params [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams]
  173. #
  174. # @param type [Symbol, :responses] The type of run data source. Always `responses`.
  175. # Determines what populates the `item` namespace in this run's data source.
  176. #
  177. # @see OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses#source
  178. 1 module Source
  179. 1 extend OpenAI::Internal::Type::Union
  180. 1 discriminator :type
  181. 1 variant :file_content,
  182. -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileContent }
  183. 1 variant :file_id, -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileID }
  184. # A EvalResponsesSource object describing a run data source configuration.
  185. 1 variant :responses,
  186. -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::Responses }
  187. 1 class FileContent < OpenAI::Internal::Type::BaseModel
  188. # @!attribute content
  189. # The content of the jsonl file.
  190. #
  191. # @return [Array<OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileContent::Content>]
  192. 1 required :content,
  193. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileContent::Content] }
  194. # @!attribute type
  195. # The type of jsonl source. Always `file_content`.
  196. #
  197. # @return [Symbol, :file_content]
  198. 1 required :type, const: :file_content
  199. # @!method initialize(content:, type: :file_content)
  200. # @param content [Array<OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileContent::Content>] The content of the jsonl file.
  201. #
  202. # @param type [Symbol, :file_content] The type of jsonl source. Always `file_content`.
  203. 1 class Content < OpenAI::Internal::Type::BaseModel
  204. # @!attribute item
  205. #
  206. # @return [Hash{Symbol=>Object}]
  207. 1 required :item, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  208. # @!attribute sample
  209. #
  210. # @return [Hash{Symbol=>Object}, nil]
  211. 1 optional :sample, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  212. # @!method initialize(item:, sample: nil)
  213. # @param item [Hash{Symbol=>Object}]
  214. # @param sample [Hash{Symbol=>Object}]
  215. end
  216. end
  217. 1 class FileID < OpenAI::Internal::Type::BaseModel
  218. # @!attribute id
  219. # The identifier of the file.
  220. #
  221. # @return [String]
  222. 1 required :id, String
  223. # @!attribute type
  224. # The type of jsonl source. Always `file_id`.
  225. #
  226. # @return [Symbol, :file_id]
  227. 1 required :type, const: :file_id
  228. # @!method initialize(id:, type: :file_id)
  229. # @param id [String] The identifier of the file.
  230. #
  231. # @param type [Symbol, :file_id] The type of jsonl source. Always `file_id`.
  232. end
  233. 1 class Responses < OpenAI::Internal::Type::BaseModel
  234. # @!attribute type
  235. # The type of run data source. Always `responses`.
  236. #
  237. # @return [Symbol, :responses]
  238. 1 required :type, const: :responses
  239. # @!attribute created_after
  240. # Only include items created after this timestamp (inclusive). This is a query
  241. # parameter used to select responses.
  242. #
  243. # @return [Integer, nil]
  244. 1 optional :created_after, Integer, nil?: true
  245. # @!attribute created_before
  246. # Only include items created before this timestamp (inclusive). This is a query
  247. # parameter used to select responses.
  248. #
  249. # @return [Integer, nil]
  250. 1 optional :created_before, Integer, nil?: true
  251. # @!attribute instructions_search
  252. # Optional string to search the 'instructions' field. This is a query parameter
  253. # used to select responses.
  254. #
  255. # @return [String, nil]
  256. 1 optional :instructions_search, String, nil?: true
  257. # @!attribute metadata
  258. # Metadata filter for the responses. This is a query parameter used to select
  259. # responses.
  260. #
  261. # @return [Object, nil]
  262. 1 optional :metadata, OpenAI::Internal::Type::Unknown, nil?: true
  263. # @!attribute model
  264. # The name of the model to find responses for. This is a query parameter used to
  265. # select responses.
  266. #
  267. # @return [String, nil]
  268. 1 optional :model, String, nil?: true
  269. # @!attribute reasoning_effort
  270. # Optional reasoning effort parameter. This is a query parameter used to select
  271. # responses.
  272. #
  273. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  274. 1 optional :reasoning_effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  275. # @!attribute temperature
  276. # Sampling temperature. This is a query parameter used to select responses.
  277. #
  278. # @return [Float, nil]
  279. 1 optional :temperature, Float, nil?: true
  280. # @!attribute tools
  281. # List of tool names. This is a query parameter used to select responses.
  282. #
  283. # @return [Array<String>, nil]
  284. 1 optional :tools, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  285. # @!attribute top_p
  286. # Nucleus sampling parameter. This is a query parameter used to select responses.
  287. #
  288. # @return [Float, nil]
  289. 1 optional :top_p, Float, nil?: true
  290. # @!attribute users
  291. # List of user identifiers. This is a query parameter used to select responses.
  292. #
  293. # @return [Array<String>, nil]
  294. 1 optional :users, OpenAI::Internal::Type::ArrayOf[String], nil?: true
  295. # @!method initialize(created_after: nil, created_before: nil, instructions_search: nil, metadata: nil, model: nil, reasoning_effort: nil, temperature: nil, tools: nil, top_p: nil, users: nil, type: :responses)
  296. # Some parameter documentations has been truncated, see
  297. # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::Responses}
  298. # for more details.
  299. #
  300. # A EvalResponsesSource object describing a run data source configuration.
  301. #
  302. # @param created_after [Integer, nil] Only include items created after this timestamp (inclusive). This is a query par
  303. #
  304. # @param created_before [Integer, nil] Only include items created before this timestamp (inclusive). This is a query pa
  305. #
  306. # @param instructions_search [String, nil] Optional string to search the 'instructions' field. This is a query parameter us
  307. #
  308. # @param metadata [Object, nil] Metadata filter for the responses. This is a query parameter used to select resp
  309. #
  310. # @param model [String, nil] The name of the model to find responses for. This is a query parameter used to s
  311. #
  312. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] Optional reasoning effort parameter. This is a query parameter used to select re
  313. #
  314. # @param temperature [Float, nil] Sampling temperature. This is a query parameter used to select responses.
  315. #
  316. # @param tools [Array<String>, nil] List of tool names. This is a query parameter used to select responses.
  317. #
  318. # @param top_p [Float, nil] Nucleus sampling parameter. This is a query parameter used to select responses.
  319. #
  320. # @param users [Array<String>, nil] List of user identifiers. This is a query parameter used to select responses.
  321. #
  322. # @param type [Symbol, :responses] The type of run data source. Always `responses`.
  323. end
  324. # @!method self.variants
  325. # @return [Array(OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileContent, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::FileID, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::Source::Responses)]
  326. end
  327. # Used when sampling from a model. Dictates the structure of the messages passed
  328. # into the model. Can either be a reference to a prebuilt trajectory (ie,
  329. # `item.input_trajectory`), or a template with variable references to the `item`
  330. # namespace.
  331. #
  332. # @see OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses#input_messages
  333. 1 module InputMessages
  334. 1 extend OpenAI::Internal::Type::Union
  335. 1 discriminator :type
  336. 1 variant :template,
  337. -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template }
  338. 1 variant :item_reference,
  339. -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::ItemReference }
  340. 1 class Template < OpenAI::Internal::Type::BaseModel
  341. # @!attribute template
  342. # A list of chat messages forming the prompt or context. May include variable
  343. # references to the `item` namespace, ie {{item.name}}.
  344. #
  345. # @return [Array<OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem>]
  346. 1 required :template,
  347. -> do
  348. OpenAI::Internal::Type::ArrayOf[
  349. union: OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template
  350. ]
  351. end
  352. # @!attribute type
  353. # The type of input messages. Always `template`.
  354. #
  355. # @return [Symbol, :template]
  356. 1 required :type, const: :template
  357. # @!method initialize(template:, type: :template)
  358. # Some parameter documentations has been truncated, see
  359. # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template}
  360. # for more details.
  361. #
  362. # @param template [Array<OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem>] A list of chat messages forming the prompt or context. May include variable refe
  363. #
  364. # @param type [Symbol, :template] The type of input messages. Always `template`.
  365. # A message input to the model with a role indicating instruction following
  366. # hierarchy. Instructions given with the `developer` or `system` role take
  367. # precedence over instructions given with the `user` role. Messages with the
  368. # `assistant` role are presumed to have been generated by the model in previous
  369. # interactions.
  370. 1 module Template
  371. 1 extend OpenAI::Internal::Type::Union
  372. 1 variant -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage }
  373. # A message input to the model with a role indicating instruction following
  374. # hierarchy. Instructions given with the `developer` or `system` role take
  375. # precedence over instructions given with the `user` role. Messages with the
  376. # `assistant` role are presumed to have been generated by the model in previous
  377. # interactions.
  378. 1 variant -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem }
  379. 1 class ChatMessage < OpenAI::Internal::Type::BaseModel
  380. # @!attribute content
  381. # The content of the message.
  382. #
  383. # @return [String]
  384. 1 required :content, String
  385. # @!attribute role
  386. # The role of the message (e.g. "system", "assistant", "user").
  387. #
  388. # @return [String]
  389. 1 required :role, String
  390. # @!method initialize(content:, role:)
  391. # @param content [String] The content of the message.
  392. #
  393. # @param role [String] The role of the message (e.g. "system", "assistant", "user").
  394. end
  395. 1 class EvalItem < OpenAI::Internal::Type::BaseModel
  396. # @!attribute content
  397. # Inputs to the model - can contain template strings.
  398. #
  399. # @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>]
  400. 1 required :content,
  401. union: -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content }
  402. # @!attribute role
  403. # The role of the message input. One of `user`, `assistant`, `system`, or
  404. # `developer`.
  405. #
  406. # @return [Symbol, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role]
  407. 1 required :role,
  408. enum: -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role }
  409. # @!attribute type
  410. # The type of the message input. Always `message`.
  411. #
  412. # @return [Symbol, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type, nil]
  413. 1 optional :type,
  414. enum: -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type }
  415. # @!method initialize(content:, role:, type: nil)
  416. # Some parameter documentations has been truncated, see
  417. # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem}
  418. # for more details.
  419. #
  420. # A message input to the model with a role indicating instruction following
  421. # hierarchy. Instructions given with the `developer` or `system` role take
  422. # precedence over instructions given with the `user` role. Messages with the
  423. # `assistant` role are presumed to have been generated by the model in previous
  424. # interactions.
  425. #
  426. # @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>] Inputs to the model - can contain template strings.
  427. #
  428. # @param role [Symbol, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  429. #
  430. # @param type [Symbol, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Type] The type of the message input. Always `message`.
  431. # Inputs to the model - can contain template strings.
  432. #
  433. # @see OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#content
  434. 1 module Content
  435. 1 extend OpenAI::Internal::Type::Union
  436. # A text input to the model.
  437. 1 variant String
  438. # A text input to the model.
  439. 1 variant -> { OpenAI::Responses::ResponseInputText }
  440. # A text output from the model.
  441. 1 variant -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText }
  442. # An image input to the model.
  443. 1 variant -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage }
  444. # A list of inputs, each of which may be either an input text or input image object.
  445. 1 variant -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::AnArrayOfInputTextAndInputImageArray }
  446. 1 class OutputText < OpenAI::Internal::Type::BaseModel
  447. # @!attribute text
  448. # The text output from the model.
  449. #
  450. # @return [String]
  451. 1 required :text, String
  452. # @!attribute type
  453. # The type of the output text. Always `output_text`.
  454. #
  455. # @return [Symbol, :output_text]
  456. 1 required :type, const: :output_text
  457. # @!method initialize(text:, type: :output_text)
  458. # Some parameter documentations has been truncated, see
  459. # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText}
  460. # for more details.
  461. #
  462. # A text output from the model.
  463. #
  464. # @param text [String] The text output from the model.
  465. #
  466. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  467. end
  468. 1 class InputImage < OpenAI::Internal::Type::BaseModel
  469. # @!attribute image_url
  470. # The URL of the image input.
  471. #
  472. # @return [String]
  473. 1 required :image_url, String
  474. # @!attribute type
  475. # The type of the image input. Always `input_image`.
  476. #
  477. # @return [Symbol, :input_image]
  478. 1 required :type, const: :input_image
  479. # @!attribute detail
  480. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  481. # `auto`. Defaults to `auto`.
  482. #
  483. # @return [String, nil]
  484. 1 optional :detail, String
  485. # @!method initialize(image_url:, detail: nil, type: :input_image)
  486. # Some parameter documentations has been truncated, see
  487. # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage}
  488. # for more details.
  489. #
  490. # An image input to the model.
  491. #
  492. # @param image_url [String] The URL of the image input.
  493. #
  494. # @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
  495. #
  496. # @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
  497. end
  498. # @!method self.variants
  499. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::OutputText, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem::Content::InputImage, Array<Object>)]
  500. # @type [OpenAI::Internal::Type::Converter]
  501. 1 AnArrayOfInputTextAndInputImageArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
  502. end
  503. # The role of the message input. One of `user`, `assistant`, `system`, or
  504. # `developer`.
  505. #
  506. # @see OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#role
  507. 1 module Role
  508. 1 extend OpenAI::Internal::Type::Enum
  509. 1 USER = :user
  510. 1 ASSISTANT = :assistant
  511. 1 SYSTEM = :system
  512. 1 DEVELOPER = :developer
  513. # @!method self.values
  514. # @return [Array<Symbol>]
  515. end
  516. # The type of the message input. Always `message`.
  517. #
  518. # @see OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem#type
  519. 1 module Type
  520. 1 extend OpenAI::Internal::Type::Enum
  521. 1 MESSAGE = :message
  522. # @!method self.values
  523. # @return [Array<Symbol>]
  524. end
  525. end
  526. # @!method self.variants
  527. # @return [Array(OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::ChatMessage, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template::Template::EvalItem)]
  528. end
  529. end
  530. 1 class ItemReference < OpenAI::Internal::Type::BaseModel
  531. # @!attribute item_reference
  532. # A reference to a variable in the `item` namespace. Ie, "item.name"
  533. #
  534. # @return [String]
  535. 1 required :item_reference, String
  536. # @!attribute type
  537. # The type of input messages. Always `item_reference`.
  538. #
  539. # @return [Symbol, :item_reference]
  540. 1 required :type, const: :item_reference
  541. # @!method initialize(item_reference:, type: :item_reference)
  542. # @param item_reference [String] A reference to a variable in the `item` namespace. Ie, "item.name"
  543. #
  544. # @param type [Symbol, :item_reference] The type of input messages. Always `item_reference`.
  545. end
  546. # @!method self.variants
  547. # @return [Array(OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::Template, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::InputMessages::ItemReference)]
  548. end
  549. # @see OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses#sampling_params
  550. 1 class SamplingParams < OpenAI::Internal::Type::BaseModel
  551. # @!attribute max_completion_tokens
  552. # The maximum number of tokens in the generated output.
  553. #
  554. # @return [Integer, nil]
  555. 1 optional :max_completion_tokens, Integer
  556. # @!attribute seed
  557. # A seed value to initialize the randomness, during sampling.
  558. #
  559. # @return [Integer, nil]
  560. 1 optional :seed, Integer
  561. # @!attribute temperature
  562. # A higher temperature increases randomness in the outputs.
  563. #
  564. # @return [Float, nil]
  565. 1 optional :temperature, Float
  566. # @!attribute text
  567. # Configuration options for a text response from the model. Can be plain text or
  568. # structured JSON data. Learn more:
  569. #
  570. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  571. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  572. #
  573. # @return [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text, nil]
  574. 1 optional :text,
  575. -> { OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text }
  576. # @!attribute tools
  577. # An array of tools the model may call while generating a response. You can
  578. # specify which tool to use by setting the `tool_choice` parameter.
  579. #
  580. # The two categories of tools you can provide the model are:
  581. #
  582. # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
  583. # capabilities, like
  584. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  585. # [file search](https://platform.openai.com/docs/guides/tools-file-search).
  586. # Learn more about
  587. # [built-in tools](https://platform.openai.com/docs/guides/tools).
  588. # - **Function calls (custom tools)**: Functions that are defined by you, enabling
  589. # the model to call your own code. Learn more about
  590. # [function calling](https://platform.openai.com/docs/guides/function-calling).
  591. #
  592. # @return [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>, nil]
  593. 1 optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] }
  594. # @!attribute top_p
  595. # An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  596. #
  597. # @return [Float, nil]
  598. 1 optional :top_p, Float
  599. # @!method initialize(max_completion_tokens: nil, seed: nil, temperature: nil, text: nil, tools: nil, top_p: nil)
  600. # Some parameter documentations has been truncated, see
  601. # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams}
  602. # for more details.
  603. #
  604. # @param max_completion_tokens [Integer] The maximum number of tokens in the generated output.
  605. #
  606. # @param seed [Integer] A seed value to initialize the randomness, during sampling.
  607. #
  608. # @param temperature [Float] A higher temperature increases randomness in the outputs.
  609. #
  610. # @param text [OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text] Configuration options for a text response from the model. Can be plain
  611. #
  612. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  613. #
  614. # @param top_p [Float] An alternative to temperature for nucleus sampling; 1.0 includes all tokens.
  615. # @see OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams#text
  616. 1 class Text < OpenAI::Internal::Type::BaseModel
  617. # @!attribute format_
  618. # An object specifying the format that the model must output.
  619. #
  620. # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
  621. # ensures the model will match your supplied JSON schema. Learn more in the
  622. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  623. #
  624. # The default format is `{ "type": "text" }` with no additional options.
  625. #
  626. # **Not recommended for gpt-4o and newer models:**
  627. #
  628. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  629. # ensures the message the model generates is valid JSON. Using `json_schema` is
  630. # preferred for models that support it.
  631. #
  632. # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil]
  633. 1 optional :format_,
  634. union: -> {
  635. OpenAI::Responses::ResponseFormatTextConfig
  636. },
  637. api_name: :format
  638. # @!method initialize(format_: nil)
  639. # Some parameter documentations has been truncated, see
  640. # {OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses::SamplingParams::Text}
  641. # for more details.
  642. #
  643. # Configuration options for a text response from the model. Can be plain text or
  644. # structured JSON data. Learn more:
  645. #
  646. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  647. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  648. #
  649. # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  650. end
  651. end
  652. end
  653. # @!method self.variants
  654. # @return [Array(OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunRetrieveResponse::DataSource::Responses)]
  655. end
  656. 1 class PerModelUsage < OpenAI::Internal::Type::BaseModel
  657. # @!attribute cached_tokens
  658. # The number of tokens retrieved from cache.
  659. #
  660. # @return [Integer]
  661. 1 required :cached_tokens, Integer
  662. # @!attribute completion_tokens
  663. # The number of completion tokens generated.
  664. #
  665. # @return [Integer]
  666. 1 required :completion_tokens, Integer
  667. # @!attribute invocation_count
  668. # The number of invocations.
  669. #
  670. # @return [Integer]
  671. 1 required :invocation_count, Integer
  672. # @!attribute model_name
  673. # The name of the model.
  674. #
  675. # @return [String]
  676. 1 required :model_name, String
  677. # @!attribute prompt_tokens
  678. # The number of prompt tokens used.
  679. #
  680. # @return [Integer]
  681. 1 required :prompt_tokens, Integer
  682. # @!attribute total_tokens
  683. # The total number of tokens used.
  684. #
  685. # @return [Integer]
  686. 1 required :total_tokens, Integer
  687. # @!method initialize(cached_tokens:, completion_tokens:, invocation_count:, model_name:, prompt_tokens:, total_tokens:)
  688. # @param cached_tokens [Integer] The number of tokens retrieved from cache.
  689. #
  690. # @param completion_tokens [Integer] The number of completion tokens generated.
  691. #
  692. # @param invocation_count [Integer] The number of invocations.
  693. #
  694. # @param model_name [String] The name of the model.
  695. #
  696. # @param prompt_tokens [Integer] The number of prompt tokens used.
  697. #
  698. # @param total_tokens [Integer] The total number of tokens used.
  699. end
  700. 1 class PerTestingCriteriaResult < OpenAI::Internal::Type::BaseModel
  701. # @!attribute failed
  702. # Number of tests failed for this criteria.
  703. #
  704. # @return [Integer]
  705. 1 required :failed, Integer
  706. # @!attribute passed
  707. # Number of tests passed for this criteria.
  708. #
  709. # @return [Integer]
  710. 1 required :passed, Integer
  711. # @!attribute testing_criteria
  712. # A description of the testing criteria.
  713. #
  714. # @return [String]
  715. 1 required :testing_criteria, String
  716. # @!method initialize(failed:, passed:, testing_criteria:)
  717. # @param failed [Integer] Number of tests failed for this criteria.
  718. #
  719. # @param passed [Integer] Number of tests passed for this criteria.
  720. #
  721. # @param testing_criteria [String] A description of the testing criteria.
  722. end
  723. # @see OpenAI::Models::Evals::RunRetrieveResponse#result_counts
  724. 1 class ResultCounts < OpenAI::Internal::Type::BaseModel
  725. # @!attribute errored
  726. # Number of output items that resulted in an error.
  727. #
  728. # @return [Integer]
  729. 1 required :errored, Integer
  730. # @!attribute failed
  731. # Number of output items that failed to pass the evaluation.
  732. #
  733. # @return [Integer]
  734. 1 required :failed, Integer
  735. # @!attribute passed
  736. # Number of output items that passed the evaluation.
  737. #
  738. # @return [Integer]
  739. 1 required :passed, Integer
  740. # @!attribute total
  741. # Total number of executed output items.
  742. #
  743. # @return [Integer]
  744. 1 required :total, Integer
  745. # @!method initialize(errored:, failed:, passed:, total:)
  746. # Counters summarizing the outcomes of the evaluation run.
  747. #
  748. # @param errored [Integer] Number of output items that resulted in an error.
  749. #
  750. # @param failed [Integer] Number of output items that failed to pass the evaluation.
  751. #
  752. # @param passed [Integer] Number of output items that passed the evaluation.
  753. #
  754. # @param total [Integer] Total number of executed output items.
  755. end
  756. end
  757. end
  758. end
  759. end

openai-ruby/lib/openai/models/evals/runs/output_item_list_params.rb

100.0% lines covered

100.0% branches covered

20 relevant lines. 20 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. 1 module Runs
  6. # @see OpenAI::Resources::Evals::Runs::OutputItems#list
  7. 1 class OutputItemListParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute eval_id
  11. #
  12. # @return [String]
  13. 1 required :eval_id, String
  14. # @!attribute after
  15. # Identifier for the last output item from the previous pagination request.
  16. #
  17. # @return [String, nil]
  18. 1 optional :after, String
  19. # @!attribute limit
  20. # Number of output items to retrieve.
  21. #
  22. # @return [Integer, nil]
  23. 1 optional :limit, Integer
  24. # @!attribute order
  25. # Sort order for output items by timestamp. Use `asc` for ascending order or
  26. # `desc` for descending order. Defaults to `asc`.
  27. #
  28. # @return [Symbol, OpenAI::Models::Evals::Runs::OutputItemListParams::Order, nil]
  29. 1 optional :order, enum: -> { OpenAI::Evals::Runs::OutputItemListParams::Order }
  30. # @!attribute status
  31. # Filter output items by status. Use `failed` to filter by failed output items or
  32. # `pass` to filter by passed output items.
  33. #
  34. # @return [Symbol, OpenAI::Models::Evals::Runs::OutputItemListParams::Status, nil]
  35. 1 optional :status, enum: -> { OpenAI::Evals::Runs::OutputItemListParams::Status }
  36. # @!method initialize(eval_id:, after: nil, limit: nil, order: nil, status: nil, request_options: {})
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Evals::Runs::OutputItemListParams} for more details.
  39. #
  40. # @param eval_id [String]
  41. #
  42. # @param after [String] Identifier for the last output item from the previous pagination request.
  43. #
  44. # @param limit [Integer] Number of output items to retrieve.
  45. #
  46. # @param order [Symbol, OpenAI::Models::Evals::Runs::OutputItemListParams::Order] Sort order for output items by timestamp. Use `asc` for ascending order or `desc
  47. #
  48. # @param status [Symbol, OpenAI::Models::Evals::Runs::OutputItemListParams::Status] Filter output items by status. Use `failed` to filter by failed output
  49. #
  50. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  51. # Sort order for output items by timestamp. Use `asc` for ascending order or
  52. # `desc` for descending order. Defaults to `asc`.
  53. 1 module Order
  54. 1 extend OpenAI::Internal::Type::Enum
  55. 1 ASC = :asc
  56. 1 DESC = :desc
  57. # @!method self.values
  58. # @return [Array<Symbol>]
  59. end
  60. # Filter output items by status. Use `failed` to filter by failed output items or
  61. # `pass` to filter by passed output items.
  62. 1 module Status
  63. 1 extend OpenAI::Internal::Type::Enum
  64. 1 FAIL = :fail
  65. 1 PASS = :pass
  66. # @!method self.values
  67. # @return [Array<Symbol>]
  68. end
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/evals/runs/output_item_list_response.rb

94.87% lines covered

100.0% branches covered

39 relevant lines. 37 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. 1 module Runs
  6. # @see OpenAI::Resources::Evals::Runs::OutputItems#list
  7. 1 class OutputItemListResponse < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # Unique identifier for the evaluation run output item.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute created_at
  14. # Unix timestamp (in seconds) when the evaluation run was created.
  15. #
  16. # @return [Integer]
  17. 1 required :created_at, Integer
  18. # @!attribute datasource_item
  19. # Details of the input data source item.
  20. #
  21. # @return [Hash{Symbol=>Object}]
  22. 1 required :datasource_item, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  23. # @!attribute datasource_item_id
  24. # The identifier for the data source item.
  25. #
  26. # @return [Integer]
  27. 1 required :datasource_item_id, Integer
  28. # @!attribute eval_id
  29. # The identifier of the evaluation group.
  30. #
  31. # @return [String]
  32. 1 required :eval_id, String
  33. # @!attribute object
  34. # The type of the object. Always "eval.run.output_item".
  35. #
  36. # @return [Symbol, :"eval.run.output_item"]
  37. 1 required :object, const: :"eval.run.output_item"
  38. # @!attribute results
  39. # A list of results from the evaluation run.
  40. #
  41. # @return [Array<Hash{Symbol=>Object}>]
  42. 1 required :results,
  43. OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]]
  44. # @!attribute run_id
  45. # The identifier of the evaluation run associated with this output item.
  46. #
  47. # @return [String]
  48. 1 required :run_id, String
  49. # @!attribute sample
  50. # A sample containing the input and output of the evaluation run.
  51. #
  52. # @return [OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample]
  53. 1 required :sample, -> { OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample }
  54. # @!attribute status
  55. # The status of the evaluation run.
  56. #
  57. # @return [String]
  58. 1 required :status, String
  59. # @!method initialize(id:, created_at:, datasource_item:, datasource_item_id:, eval_id:, results:, run_id:, sample:, status:, object: :"eval.run.output_item")
  60. # A schema representing an evaluation run output item.
  61. #
  62. # @param id [String] Unique identifier for the evaluation run output item.
  63. #
  64. # @param created_at [Integer] Unix timestamp (in seconds) when the evaluation run was created.
  65. #
  66. # @param datasource_item [Hash{Symbol=>Object}] Details of the input data source item.
  67. #
  68. # @param datasource_item_id [Integer] The identifier for the data source item.
  69. #
  70. # @param eval_id [String] The identifier of the evaluation group.
  71. #
  72. # @param results [Array<Hash{Symbol=>Object}>] A list of results from the evaluation run.
  73. #
  74. # @param run_id [String] The identifier of the evaluation run associated with this output item.
  75. #
  76. # @param sample [OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample] A sample containing the input and output of the evaluation run.
  77. #
  78. # @param status [String] The status of the evaluation run.
  79. #
  80. # @param object [Symbol, :"eval.run.output_item"] The type of the object. Always "eval.run.output_item".
  81. # @see OpenAI::Models::Evals::Runs::OutputItemListResponse#sample
  82. 1 class Sample < OpenAI::Internal::Type::BaseModel
  83. # @!attribute error
  84. # An object representing an error response from the Eval API.
  85. #
  86. # @return [OpenAI::Models::Evals::EvalAPIError]
  87. 1 required :error, -> { OpenAI::Evals::EvalAPIError }
  88. # @!attribute finish_reason
  89. # The reason why the sample generation was finished.
  90. #
  91. # @return [String]
  92. 1 required :finish_reason, String
  93. # @!attribute input
  94. # An array of input messages.
  95. #
  96. # @return [Array<OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample::Input>]
  97. 1 required :input,
  98. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample::Input] }
  99. # @!attribute max_completion_tokens
  100. # The maximum number of tokens allowed for completion.
  101. #
  102. # @return [Integer]
  103. 1 required :max_completion_tokens, Integer
  104. # @!attribute model
  105. # The model used for generating the sample.
  106. #
  107. # @return [String]
  108. 1 required :model, String
  109. # @!attribute output
  110. # An array of output messages.
  111. #
  112. # @return [Array<OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample::Output>]
  113. 1 required :output,
  114. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample::Output] }
  115. # @!attribute seed
  116. # The seed used for generating the sample.
  117. #
  118. # @return [Integer]
  119. 1 required :seed, Integer
  120. # @!attribute temperature
  121. # The sampling temperature used.
  122. #
  123. # @return [Float]
  124. 1 required :temperature, Float
  125. # @!attribute top_p
  126. # The top_p value used for sampling.
  127. #
  128. # @return [Float]
  129. 1 required :top_p, Float
  130. # @!attribute usage
  131. # Token usage details for the sample.
  132. #
  133. # @return [OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample::Usage]
  134. 1 required :usage, -> { OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample::Usage }
  135. # @!method initialize(error:, finish_reason:, input:, max_completion_tokens:, model:, output:, seed:, temperature:, top_p:, usage:)
  136. # Some parameter documentations has been truncated, see
  137. # {OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample} for more details.
  138. #
  139. # A sample containing the input and output of the evaluation run.
  140. #
  141. # @param error [OpenAI::Models::Evals::EvalAPIError] An object representing an error response from the Eval API.
  142. #
  143. # @param finish_reason [String] The reason why the sample generation was finished.
  144. #
  145. # @param input [Array<OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample::Input>] An array of input messages.
  146. #
  147. # @param max_completion_tokens [Integer] The maximum number of tokens allowed for completion.
  148. #
  149. # @param model [String] The model used for generating the sample.
  150. #
  151. # @param output [Array<OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample::Output>] An array of output messages.
  152. #
  153. # @param seed [Integer] The seed used for generating the sample.
  154. #
  155. # @param temperature [Float] The sampling temperature used.
  156. #
  157. # @param top_p [Float] The top_p value used for sampling.
  158. #
  159. # @param usage [OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample::Usage] Token usage details for the sample.
  160. 1 class Input < OpenAI::Internal::Type::BaseModel
  161. # @!attribute content
  162. # The content of the message.
  163. #
  164. # @return [String]
  165. 1 required :content, String
  166. # @!attribute role
  167. # The role of the message sender (e.g., system, user, developer).
  168. #
  169. # @return [String]
  170. 1 required :role, String
  171. # @!method initialize(content:, role:)
  172. # An input message.
  173. #
  174. # @param content [String] The content of the message.
  175. #
  176. # @param role [String] The role of the message sender (e.g., system, user, developer).
  177. end
  178. 1 class Output < OpenAI::Internal::Type::BaseModel
  179. # @!attribute content
  180. # The content of the message.
  181. #
  182. # @return [String, nil]
  183. 1 optional :content, String
  184. # @!attribute role
  185. # The role of the message (e.g. "system", "assistant", "user").
  186. #
  187. # @return [String, nil]
  188. 1 optional :role, String
  189. # @!method initialize(content: nil, role: nil)
  190. # @param content [String] The content of the message.
  191. #
  192. # @param role [String] The role of the message (e.g. "system", "assistant", "user").
  193. end
  194. # @see OpenAI::Models::Evals::Runs::OutputItemListResponse::Sample#usage
  195. 1 class Usage < OpenAI::Internal::Type::BaseModel
  196. # @!attribute cached_tokens
  197. # The number of tokens retrieved from cache.
  198. #
  199. # @return [Integer]
  200. 1 required :cached_tokens, Integer
  201. # @!attribute completion_tokens
  202. # The number of completion tokens generated.
  203. #
  204. # @return [Integer]
  205. 1 required :completion_tokens, Integer
  206. # @!attribute prompt_tokens
  207. # The number of prompt tokens used.
  208. #
  209. # @return [Integer]
  210. 1 required :prompt_tokens, Integer
  211. # @!attribute total_tokens
  212. # The total number of tokens used.
  213. #
  214. # @return [Integer]
  215. 1 required :total_tokens, Integer
  216. # @!method initialize(cached_tokens:, completion_tokens:, prompt_tokens:, total_tokens:)
  217. # Token usage details for the sample.
  218. #
  219. # @param cached_tokens [Integer] The number of tokens retrieved from cache.
  220. #
  221. # @param completion_tokens [Integer] The number of completion tokens generated.
  222. #
  223. # @param prompt_tokens [Integer] The number of prompt tokens used.
  224. #
  225. # @param total_tokens [Integer] The total number of tokens used.
  226. end
  227. end
  228. end
  229. end
  230. end
  231. end
  232. end

openai-ruby/lib/openai/models/evals/runs/output_item_retrieve_params.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. 1 module Runs
  6. # @see OpenAI::Resources::Evals::Runs::OutputItems#retrieve
  7. 1 class OutputItemRetrieveParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute eval_id
  11. #
  12. # @return [String]
  13. 1 required :eval_id, String
  14. # @!attribute run_id
  15. #
  16. # @return [String]
  17. 1 required :run_id, String
  18. # @!method initialize(eval_id:, run_id:, request_options: {})
  19. # @param eval_id [String]
  20. # @param run_id [String]
  21. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  22. end
  23. end
  24. end
  25. end
  26. end

openai-ruby/lib/openai/models/evals/runs/output_item_retrieve_response.rb

94.87% lines covered

100.0% branches covered

39 relevant lines. 37 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Evals
  5. 1 module Runs
  6. # @see OpenAI::Resources::Evals::Runs::OutputItems#retrieve
  7. 1 class OutputItemRetrieveResponse < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # Unique identifier for the evaluation run output item.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute created_at
  14. # Unix timestamp (in seconds) when the evaluation run was created.
  15. #
  16. # @return [Integer]
  17. 1 required :created_at, Integer
  18. # @!attribute datasource_item
  19. # Details of the input data source item.
  20. #
  21. # @return [Hash{Symbol=>Object}]
  22. 1 required :datasource_item, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  23. # @!attribute datasource_item_id
  24. # The identifier for the data source item.
  25. #
  26. # @return [Integer]
  27. 1 required :datasource_item_id, Integer
  28. # @!attribute eval_id
  29. # The identifier of the evaluation group.
  30. #
  31. # @return [String]
  32. 1 required :eval_id, String
  33. # @!attribute object
  34. # The type of the object. Always "eval.run.output_item".
  35. #
  36. # @return [Symbol, :"eval.run.output_item"]
  37. 1 required :object, const: :"eval.run.output_item"
  38. # @!attribute results
  39. # A list of results from the evaluation run.
  40. #
  41. # @return [Array<Hash{Symbol=>Object}>]
  42. 1 required :results,
  43. OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]]
  44. # @!attribute run_id
  45. # The identifier of the evaluation run associated with this output item.
  46. #
  47. # @return [String]
  48. 1 required :run_id, String
  49. # @!attribute sample
  50. # A sample containing the input and output of the evaluation run.
  51. #
  52. # @return [OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample]
  53. 1 required :sample, -> { OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample }
  54. # @!attribute status
  55. # The status of the evaluation run.
  56. #
  57. # @return [String]
  58. 1 required :status, String
  59. # @!method initialize(id:, created_at:, datasource_item:, datasource_item_id:, eval_id:, results:, run_id:, sample:, status:, object: :"eval.run.output_item")
  60. # A schema representing an evaluation run output item.
  61. #
  62. # @param id [String] Unique identifier for the evaluation run output item.
  63. #
  64. # @param created_at [Integer] Unix timestamp (in seconds) when the evaluation run was created.
  65. #
  66. # @param datasource_item [Hash{Symbol=>Object}] Details of the input data source item.
  67. #
  68. # @param datasource_item_id [Integer] The identifier for the data source item.
  69. #
  70. # @param eval_id [String] The identifier of the evaluation group.
  71. #
  72. # @param results [Array<Hash{Symbol=>Object}>] A list of results from the evaluation run.
  73. #
  74. # @param run_id [String] The identifier of the evaluation run associated with this output item.
  75. #
  76. # @param sample [OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample] A sample containing the input and output of the evaluation run.
  77. #
  78. # @param status [String] The status of the evaluation run.
  79. #
  80. # @param object [Symbol, :"eval.run.output_item"] The type of the object. Always "eval.run.output_item".
  81. # @see OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse#sample
  82. 1 class Sample < OpenAI::Internal::Type::BaseModel
  83. # @!attribute error
  84. # An object representing an error response from the Eval API.
  85. #
  86. # @return [OpenAI::Models::Evals::EvalAPIError]
  87. 1 required :error, -> { OpenAI::Evals::EvalAPIError }
  88. # @!attribute finish_reason
  89. # The reason why the sample generation was finished.
  90. #
  91. # @return [String]
  92. 1 required :finish_reason, String
  93. # @!attribute input
  94. # An array of input messages.
  95. #
  96. # @return [Array<OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample::Input>]
  97. 1 required :input,
  98. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample::Input] }
  99. # @!attribute max_completion_tokens
  100. # The maximum number of tokens allowed for completion.
  101. #
  102. # @return [Integer]
  103. 1 required :max_completion_tokens, Integer
  104. # @!attribute model
  105. # The model used for generating the sample.
  106. #
  107. # @return [String]
  108. 1 required :model, String
  109. # @!attribute output
  110. # An array of output messages.
  111. #
  112. # @return [Array<OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample::Output>]
  113. 1 required :output,
  114. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample::Output] }
  115. # @!attribute seed
  116. # The seed used for generating the sample.
  117. #
  118. # @return [Integer]
  119. 1 required :seed, Integer
  120. # @!attribute temperature
  121. # The sampling temperature used.
  122. #
  123. # @return [Float]
  124. 1 required :temperature, Float
  125. # @!attribute top_p
  126. # The top_p value used for sampling.
  127. #
  128. # @return [Float]
  129. 1 required :top_p, Float
  130. # @!attribute usage
  131. # Token usage details for the sample.
  132. #
  133. # @return [OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample::Usage]
  134. 1 required :usage, -> { OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample::Usage }
  135. # @!method initialize(error:, finish_reason:, input:, max_completion_tokens:, model:, output:, seed:, temperature:, top_p:, usage:)
  136. # Some parameter documentations has been truncated, see
  137. # {OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample} for more
  138. # details.
  139. #
  140. # A sample containing the input and output of the evaluation run.
  141. #
  142. # @param error [OpenAI::Models::Evals::EvalAPIError] An object representing an error response from the Eval API.
  143. #
  144. # @param finish_reason [String] The reason why the sample generation was finished.
  145. #
  146. # @param input [Array<OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample::Input>] An array of input messages.
  147. #
  148. # @param max_completion_tokens [Integer] The maximum number of tokens allowed for completion.
  149. #
  150. # @param model [String] The model used for generating the sample.
  151. #
  152. # @param output [Array<OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample::Output>] An array of output messages.
  153. #
  154. # @param seed [Integer] The seed used for generating the sample.
  155. #
  156. # @param temperature [Float] The sampling temperature used.
  157. #
  158. # @param top_p [Float] The top_p value used for sampling.
  159. #
  160. # @param usage [OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample::Usage] Token usage details for the sample.
  161. 1 class Input < OpenAI::Internal::Type::BaseModel
  162. # @!attribute content
  163. # The content of the message.
  164. #
  165. # @return [String]
  166. 1 required :content, String
  167. # @!attribute role
  168. # The role of the message sender (e.g., system, user, developer).
  169. #
  170. # @return [String]
  171. 1 required :role, String
  172. # @!method initialize(content:, role:)
  173. # An input message.
  174. #
  175. # @param content [String] The content of the message.
  176. #
  177. # @param role [String] The role of the message sender (e.g., system, user, developer).
  178. end
  179. 1 class Output < OpenAI::Internal::Type::BaseModel
  180. # @!attribute content
  181. # The content of the message.
  182. #
  183. # @return [String, nil]
  184. 1 optional :content, String
  185. # @!attribute role
  186. # The role of the message (e.g. "system", "assistant", "user").
  187. #
  188. # @return [String, nil]
  189. 1 optional :role, String
  190. # @!method initialize(content: nil, role: nil)
  191. # @param content [String] The content of the message.
  192. #
  193. # @param role [String] The role of the message (e.g. "system", "assistant", "user").
  194. end
  195. # @see OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse::Sample#usage
  196. 1 class Usage < OpenAI::Internal::Type::BaseModel
  197. # @!attribute cached_tokens
  198. # The number of tokens retrieved from cache.
  199. #
  200. # @return [Integer]
  201. 1 required :cached_tokens, Integer
  202. # @!attribute completion_tokens
  203. # The number of completion tokens generated.
  204. #
  205. # @return [Integer]
  206. 1 required :completion_tokens, Integer
  207. # @!attribute prompt_tokens
  208. # The number of prompt tokens used.
  209. #
  210. # @return [Integer]
  211. 1 required :prompt_tokens, Integer
  212. # @!attribute total_tokens
  213. # The total number of tokens used.
  214. #
  215. # @return [Integer]
  216. 1 required :total_tokens, Integer
  217. # @!method initialize(cached_tokens:, completion_tokens:, prompt_tokens:, total_tokens:)
  218. # Token usage details for the sample.
  219. #
  220. # @param cached_tokens [Integer] The number of tokens retrieved from cache.
  221. #
  222. # @param completion_tokens [Integer] The number of completion tokens generated.
  223. #
  224. # @param prompt_tokens [Integer] The number of prompt tokens used.
  225. #
  226. # @param total_tokens [Integer] The total number of tokens used.
  227. end
  228. end
  229. end
  230. end
  231. end
  232. end
  233. end

openai-ruby/lib/openai/models/file_chunking_strategy.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # The strategy used to chunk the file.
  5. 1 module FileChunkingStrategy
  6. 1 extend OpenAI::Internal::Type::Union
  7. 1 discriminator :type
  8. 1 variant :static, -> { OpenAI::StaticFileChunkingStrategyObject }
  9. # This is returned when the chunking strategy is unknown. Typically, this is because the file was indexed before the `chunking_strategy` concept was introduced in the API.
  10. 1 variant :other, -> { OpenAI::OtherFileChunkingStrategyObject }
  11. # @!method self.variants
  12. # @return [Array(OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject)]
  13. end
  14. end
  15. end

openai-ruby/lib/openai/models/file_chunking_strategy_param.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  5. # strategy. Only applicable if `file_ids` is non-empty.
  6. 1 module FileChunkingStrategyParam
  7. 1 extend OpenAI::Internal::Type::Union
  8. 1 discriminator :type
  9. # The default strategy. This strategy currently uses a `max_chunk_size_tokens` of `800` and `chunk_overlap_tokens` of `400`.
  10. 1 variant :auto, -> { OpenAI::AutoFileChunkingStrategyParam }
  11. # Customize your own chunking strategy by setting chunk size and chunk overlap.
  12. 1 variant :static, -> { OpenAI::StaticFileChunkingStrategyObjectParam }
  13. # @!method self.variants
  14. # @return [Array(OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam)]
  15. end
  16. end
  17. end

openai-ruby/lib/openai/models/file_content.rb

100.0% lines covered

100.0% branches covered

3 relevant lines. 3 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 FileContent = String
  5. end
  6. end

openai-ruby/lib/openai/models/file_content_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Files#content
  5. 1 class FileContentParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/file_create_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Files#create
  5. 1 class FileCreateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute file
  9. # The File object (not file name) to be uploaded.
  10. #
  11. # @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
  12. 1 required :file, OpenAI::Internal::Type::FileInput
  13. # @!attribute purpose
  14. # The intended purpose of the uploaded file. One of: - `assistants`: Used in the
  15. # Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
  16. # fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
  17. # Flexible file type for any purpose - `evals`: Used for eval data sets
  18. #
  19. # @return [Symbol, OpenAI::Models::FilePurpose]
  20. 1 required :purpose, enum: -> { OpenAI::FilePurpose }
  21. # @!method initialize(file:, purpose:, request_options: {})
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::FileCreateParams} for more details.
  24. #
  25. # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The File object (not file name) to be uploaded.
  26. #
  27. # @param purpose [Symbol, OpenAI::Models::FilePurpose] The intended purpose of the uploaded file. One of: - `assistants`: Used in the A
  28. #
  29. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  30. end
  31. end
  32. end

openai-ruby/lib/openai/models/file_delete_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Files#delete
  5. 1 class FileDeleteParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/file_deleted.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Files#delete
  5. 1 class FileDeleted < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. #
  8. # @return [String]
  9. 1 required :id, String
  10. # @!attribute deleted
  11. #
  12. # @return [Boolean]
  13. 1 required :deleted, OpenAI::Internal::Type::Boolean
  14. # @!attribute object
  15. #
  16. # @return [Symbol, :file]
  17. 1 required :object, const: :file
  18. # @!method initialize(id:, deleted:, object: :file)
  19. # @param id [String]
  20. # @param deleted [Boolean]
  21. # @param object [Symbol, :file]
  22. end
  23. end
  24. end

openai-ruby/lib/openai/models/file_list_params.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Files#list
  5. 1 class FileListParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute after
  9. # A cursor for use in pagination. `after` is an object ID that defines your place
  10. # in the list. For instance, if you make a list request and receive 100 objects,
  11. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  12. # fetch the next page of the list.
  13. #
  14. # @return [String, nil]
  15. 1 optional :after, String
  16. # @!attribute limit
  17. # A limit on the number of objects to be returned. Limit can range between 1 and
  18. # 10,000, and the default is 10,000.
  19. #
  20. # @return [Integer, nil]
  21. 1 optional :limit, Integer
  22. # @!attribute order
  23. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  24. # order and `desc` for descending order.
  25. #
  26. # @return [Symbol, OpenAI::Models::FileListParams::Order, nil]
  27. 1 optional :order, enum: -> { OpenAI::FileListParams::Order }
  28. # @!attribute purpose
  29. # Only return files with the given purpose.
  30. #
  31. # @return [String, nil]
  32. 1 optional :purpose, String
  33. # @!method initialize(after: nil, limit: nil, order: nil, purpose: nil, request_options: {})
  34. # Some parameter documentations has been truncated, see
  35. # {OpenAI::Models::FileListParams} for more details.
  36. #
  37. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  38. #
  39. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  40. #
  41. # @param order [Symbol, OpenAI::Models::FileListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  42. #
  43. # @param purpose [String] Only return files with the given purpose.
  44. #
  45. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  46. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  47. # order and `desc` for descending order.
  48. 1 module Order
  49. 1 extend OpenAI::Internal::Type::Enum
  50. 1 ASC = :asc
  51. 1 DESC = :desc
  52. # @!method self.values
  53. # @return [Array<Symbol>]
  54. end
  55. end
  56. end
  57. end

openai-ruby/lib/openai/models/file_object.rb

100.0% lines covered

100.0% branches covered

27 relevant lines. 27 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Files#create
  5. 1 class FileObject < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The file identifier, which can be referenced in the API endpoints.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute bytes
  12. # The size of the file, in bytes.
  13. #
  14. # @return [Integer]
  15. 1 required :bytes, Integer
  16. # @!attribute created_at
  17. # The Unix timestamp (in seconds) for when the file was created.
  18. #
  19. # @return [Integer]
  20. 1 required :created_at, Integer
  21. # @!attribute filename
  22. # The name of the file.
  23. #
  24. # @return [String]
  25. 1 required :filename, String
  26. # @!attribute object
  27. # The object type, which is always `file`.
  28. #
  29. # @return [Symbol, :file]
  30. 1 required :object, const: :file
  31. # @!attribute purpose
  32. # The intended purpose of the file. Supported values are `assistants`,
  33. # `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,
  34. # `vision`, and `user_data`.
  35. #
  36. # @return [Symbol, OpenAI::Models::FileObject::Purpose]
  37. 1 required :purpose, enum: -> { OpenAI::FileObject::Purpose }
  38. # @!attribute status
  39. # @deprecated
  40. #
  41. # Deprecated. The current status of the file, which can be either `uploaded`,
  42. # `processed`, or `error`.
  43. #
  44. # @return [Symbol, OpenAI::Models::FileObject::Status]
  45. 1 required :status, enum: -> { OpenAI::FileObject::Status }
  46. # @!attribute expires_at
  47. # The Unix timestamp (in seconds) for when the file will expire.
  48. #
  49. # @return [Integer, nil]
  50. 1 optional :expires_at, Integer
  51. # @!attribute status_details
  52. # @deprecated
  53. #
  54. # Deprecated. For details on why a fine-tuning training file failed validation,
  55. # see the `error` field on `fine_tuning.job`.
  56. #
  57. # @return [String, nil]
  58. 1 optional :status_details, String
  59. # @!method initialize(id:, bytes:, created_at:, filename:, purpose:, status:, expires_at: nil, status_details: nil, object: :file)
  60. # Some parameter documentations has been truncated, see
  61. # {OpenAI::Models::FileObject} for more details.
  62. #
  63. # The `File` object represents a document that has been uploaded to OpenAI.
  64. #
  65. # @param id [String] The file identifier, which can be referenced in the API endpoints.
  66. #
  67. # @param bytes [Integer] The size of the file, in bytes.
  68. #
  69. # @param created_at [Integer] The Unix timestamp (in seconds) for when the file was created.
  70. #
  71. # @param filename [String] The name of the file.
  72. #
  73. # @param purpose [Symbol, OpenAI::Models::FileObject::Purpose] The intended purpose of the file. Supported values are `assistants`, `assistants
  74. #
  75. # @param status [Symbol, OpenAI::Models::FileObject::Status] Deprecated. The current status of the file, which can be either `uploaded`, `pro
  76. #
  77. # @param expires_at [Integer] The Unix timestamp (in seconds) for when the file will expire.
  78. #
  79. # @param status_details [String] Deprecated. For details on why a fine-tuning training file failed validation, se
  80. #
  81. # @param object [Symbol, :file] The object type, which is always `file`.
  82. # The intended purpose of the file. Supported values are `assistants`,
  83. # `assistants_output`, `batch`, `batch_output`, `fine-tune`, `fine-tune-results`,
  84. # `vision`, and `user_data`.
  85. #
  86. # @see OpenAI::Models::FileObject#purpose
  87. 1 module Purpose
  88. 1 extend OpenAI::Internal::Type::Enum
  89. 1 ASSISTANTS = :assistants
  90. 1 ASSISTANTS_OUTPUT = :assistants_output
  91. 1 BATCH = :batch
  92. 1 BATCH_OUTPUT = :batch_output
  93. 1 FINE_TUNE = :"fine-tune"
  94. 1 FINE_TUNE_RESULTS = :"fine-tune-results"
  95. 1 VISION = :vision
  96. 1 USER_DATA = :user_data
  97. # @!method self.values
  98. # @return [Array<Symbol>]
  99. end
  100. # @deprecated
  101. #
  102. # Deprecated. The current status of the file, which can be either `uploaded`,
  103. # `processed`, or `error`.
  104. #
  105. # @see OpenAI::Models::FileObject#status
  106. 1 module Status
  107. 1 extend OpenAI::Internal::Type::Enum
  108. 1 UPLOADED = :uploaded
  109. 1 PROCESSED = :processed
  110. 1 ERROR = :error
  111. # @!method self.values
  112. # @return [Array<Symbol>]
  113. end
  114. end
  115. end
  116. end

openai-ruby/lib/openai/models/file_purpose.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # The intended purpose of the uploaded file. One of: - `assistants`: Used in the
  5. # Assistants API - `batch`: Used in the Batch API - `fine-tune`: Used for
  6. # fine-tuning - `vision`: Images used for vision fine-tuning - `user_data`:
  7. # Flexible file type for any purpose - `evals`: Used for eval data sets
  8. 1 module FilePurpose
  9. 1 extend OpenAI::Internal::Type::Enum
  10. 1 ASSISTANTS = :assistants
  11. 1 BATCH = :batch
  12. 1 FINE_TUNE = :"fine-tune"
  13. 1 VISION = :vision
  14. 1 USER_DATA = :user_data
  15. 1 EVALS = :evals
  16. # @!method self.values
  17. # @return [Array<Symbol>]
  18. end
  19. end
  20. end

openai-ruby/lib/openai/models/file_retrieve_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Files#retrieve
  5. 1 class FileRetrieveParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/fine_tuning/alpha/grader_run_params.rb

100.0% lines covered

100.0% branches covered

18 relevant lines. 18 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Alpha
  6. # @see OpenAI::Resources::FineTuning::Alpha::Graders#run
  7. 1 class GraderRunParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute grader
  11. # The grader used for the fine-tuning job.
  12. #
  13. # @return [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader]
  14. 1 required :grader, union: -> { OpenAI::FineTuning::Alpha::GraderRunParams::Grader }
  15. # @!attribute model_sample
  16. # The model sample to be evaluated. This value will be used to populate the
  17. # `sample` namespace. See
  18. # [the guide](https://platform.openai.com/docs/guides/graders) for more details.
  19. # The `output_json` variable will be populated if the model sample is a valid JSON
  20. # string.
  21. #
  22. # @return [String]
  23. 1 required :model_sample, String
  24. # @!attribute item
  25. # The dataset item provided to the grader. This will be used to populate the
  26. # `item` namespace. See
  27. # [the guide](https://platform.openai.com/docs/guides/graders) for more details.
  28. #
  29. # @return [Object, nil]
  30. 1 optional :item, OpenAI::Internal::Type::Unknown
  31. # @!method initialize(grader:, model_sample:, item: nil, request_options: {})
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::FineTuning::Alpha::GraderRunParams} for more details.
  34. #
  35. # @param grader [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader] The grader used for the fine-tuning job.
  36. #
  37. # @param model_sample [String] The model sample to be evaluated. This value will be used to populate
  38. #
  39. # @param item [Object] The dataset item provided to the grader. This will be used to populate
  40. #
  41. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  42. # The grader used for the fine-tuning job.
  43. 1 module Grader
  44. 1 extend OpenAI::Internal::Type::Union
  45. 1 discriminator :type
  46. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  47. 1 variant :string_check, -> { OpenAI::Graders::StringCheckGrader }
  48. # A TextSimilarityGrader object which grades text based on similarity metrics.
  49. 1 variant :text_similarity, -> { OpenAI::Graders::TextSimilarityGrader }
  50. # A PythonGrader object that runs a python script on the input.
  51. 1 variant :python, -> { OpenAI::Graders::PythonGrader }
  52. # A ScoreModelGrader object that uses a model to assign a score to the input.
  53. 1 variant :score_model, -> { OpenAI::Graders::ScoreModelGrader }
  54. # A MultiGrader object combines the output of multiple graders to produce a single score.
  55. 1 variant :multi, -> { OpenAI::Graders::MultiGrader }
  56. # @!method self.variants
  57. # @return [Array(OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader)]
  58. end
  59. end
  60. end
  61. end
  62. end
  63. end

openai-ruby/lib/openai/models/fine_tuning/alpha/grader_run_response.rb

100.0% lines covered

100.0% branches covered

32 relevant lines. 32 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Alpha
  6. # @see OpenAI::Resources::FineTuning::Alpha::Graders#run
  7. 1 class GraderRunResponse < OpenAI::Internal::Type::BaseModel
  8. # @!attribute metadata
  9. #
  10. # @return [OpenAI::Models::FineTuning::Alpha::GraderRunResponse::Metadata]
  11. 1 required :metadata, -> { OpenAI::Models::FineTuning::Alpha::GraderRunResponse::Metadata }
  12. # @!attribute model_grader_token_usage_per_model
  13. #
  14. # @return [Hash{Symbol=>Object}]
  15. 1 required :model_grader_token_usage_per_model,
  16. OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  17. # @!attribute reward
  18. #
  19. # @return [Float]
  20. 1 required :reward, Float
  21. # @!attribute sub_rewards
  22. #
  23. # @return [Hash{Symbol=>Object}]
  24. 1 required :sub_rewards, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  25. # @!method initialize(metadata:, model_grader_token_usage_per_model:, reward:, sub_rewards:)
  26. # @param metadata [OpenAI::Models::FineTuning::Alpha::GraderRunResponse::Metadata]
  27. # @param model_grader_token_usage_per_model [Hash{Symbol=>Object}]
  28. # @param reward [Float]
  29. # @param sub_rewards [Hash{Symbol=>Object}]
  30. # @see OpenAI::Models::FineTuning::Alpha::GraderRunResponse#metadata
  31. 1 class Metadata < OpenAI::Internal::Type::BaseModel
  32. # @!attribute errors
  33. #
  34. # @return [OpenAI::Models::FineTuning::Alpha::GraderRunResponse::Metadata::Errors]
  35. 1 required :errors, -> { OpenAI::Models::FineTuning::Alpha::GraderRunResponse::Metadata::Errors }
  36. # @!attribute execution_time
  37. #
  38. # @return [Float]
  39. 1 required :execution_time, Float
  40. # @!attribute name
  41. #
  42. # @return [String]
  43. 1 required :name, String
  44. # @!attribute sampled_model_name
  45. #
  46. # @return [String, nil]
  47. 1 required :sampled_model_name, String, nil?: true
  48. # @!attribute scores
  49. #
  50. # @return [Hash{Symbol=>Object}]
  51. 1 required :scores, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  52. # @!attribute token_usage
  53. #
  54. # @return [Integer, nil]
  55. 1 required :token_usage, Integer, nil?: true
  56. # @!attribute type
  57. #
  58. # @return [String]
  59. 1 required :type, String
  60. # @!method initialize(errors:, execution_time:, name:, sampled_model_name:, scores:, token_usage:, type:)
  61. # @param errors [OpenAI::Models::FineTuning::Alpha::GraderRunResponse::Metadata::Errors]
  62. # @param execution_time [Float]
  63. # @param name [String]
  64. # @param sampled_model_name [String, nil]
  65. # @param scores [Hash{Symbol=>Object}]
  66. # @param token_usage [Integer, nil]
  67. # @param type [String]
  68. # @see OpenAI::Models::FineTuning::Alpha::GraderRunResponse::Metadata#errors
  69. 1 class Errors < OpenAI::Internal::Type::BaseModel
  70. # @!attribute formula_parse_error
  71. #
  72. # @return [Boolean]
  73. 1 required :formula_parse_error, OpenAI::Internal::Type::Boolean
  74. # @!attribute invalid_variable_error
  75. #
  76. # @return [Boolean]
  77. 1 required :invalid_variable_error, OpenAI::Internal::Type::Boolean
  78. # @!attribute model_grader_parse_error
  79. #
  80. # @return [Boolean]
  81. 1 required :model_grader_parse_error, OpenAI::Internal::Type::Boolean
  82. # @!attribute model_grader_refusal_error
  83. #
  84. # @return [Boolean]
  85. 1 required :model_grader_refusal_error, OpenAI::Internal::Type::Boolean
  86. # @!attribute model_grader_server_error
  87. #
  88. # @return [Boolean]
  89. 1 required :model_grader_server_error, OpenAI::Internal::Type::Boolean
  90. # @!attribute model_grader_server_error_details
  91. #
  92. # @return [String, nil]
  93. 1 required :model_grader_server_error_details, String, nil?: true
  94. # @!attribute other_error
  95. #
  96. # @return [Boolean]
  97. 1 required :other_error, OpenAI::Internal::Type::Boolean
  98. # @!attribute python_grader_runtime_error
  99. #
  100. # @return [Boolean]
  101. 1 required :python_grader_runtime_error, OpenAI::Internal::Type::Boolean
  102. # @!attribute python_grader_runtime_error_details
  103. #
  104. # @return [String, nil]
  105. 1 required :python_grader_runtime_error_details, String, nil?: true
  106. # @!attribute python_grader_server_error
  107. #
  108. # @return [Boolean]
  109. 1 required :python_grader_server_error, OpenAI::Internal::Type::Boolean
  110. # @!attribute python_grader_server_error_type
  111. #
  112. # @return [String, nil]
  113. 1 required :python_grader_server_error_type, String, nil?: true
  114. # @!attribute sample_parse_error
  115. #
  116. # @return [Boolean]
  117. 1 required :sample_parse_error, OpenAI::Internal::Type::Boolean
  118. # @!attribute truncated_observation_error
  119. #
  120. # @return [Boolean]
  121. 1 required :truncated_observation_error, OpenAI::Internal::Type::Boolean
  122. # @!attribute unresponsive_reward_error
  123. #
  124. # @return [Boolean]
  125. 1 required :unresponsive_reward_error, OpenAI::Internal::Type::Boolean
  126. # @!method initialize(formula_parse_error:, invalid_variable_error:, model_grader_parse_error:, model_grader_refusal_error:, model_grader_server_error:, model_grader_server_error_details:, other_error:, python_grader_runtime_error:, python_grader_runtime_error_details:, python_grader_server_error:, python_grader_server_error_type:, sample_parse_error:, truncated_observation_error:, unresponsive_reward_error:)
  127. # @param formula_parse_error [Boolean]
  128. # @param invalid_variable_error [Boolean]
  129. # @param model_grader_parse_error [Boolean]
  130. # @param model_grader_refusal_error [Boolean]
  131. # @param model_grader_server_error [Boolean]
  132. # @param model_grader_server_error_details [String, nil]
  133. # @param other_error [Boolean]
  134. # @param python_grader_runtime_error [Boolean]
  135. # @param python_grader_runtime_error_details [String, nil]
  136. # @param python_grader_server_error [Boolean]
  137. # @param python_grader_server_error_type [String, nil]
  138. # @param sample_parse_error [Boolean]
  139. # @param truncated_observation_error [Boolean]
  140. # @param unresponsive_reward_error [Boolean]
  141. end
  142. end
  143. end
  144. end
  145. end
  146. end
  147. end

openai-ruby/lib/openai/models/fine_tuning/alpha/grader_validate_params.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Alpha
  6. # @see OpenAI::Resources::FineTuning::Alpha::Graders#validate
  7. 1 class GraderValidateParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute grader
  11. # The grader used for the fine-tuning job.
  12. #
  13. # @return [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader]
  14. 1 required :grader, union: -> { OpenAI::FineTuning::Alpha::GraderValidateParams::Grader }
  15. # @!method initialize(grader:, request_options: {})
  16. # @param grader [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader] The grader used for the fine-tuning job.
  17. #
  18. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  19. # The grader used for the fine-tuning job.
  20. 1 module Grader
  21. 1 extend OpenAI::Internal::Type::Union
  22. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  23. 1 variant -> { OpenAI::Graders::StringCheckGrader }
  24. # A TextSimilarityGrader object which grades text based on similarity metrics.
  25. 1 variant -> { OpenAI::Graders::TextSimilarityGrader }
  26. # A PythonGrader object that runs a python script on the input.
  27. 1 variant -> { OpenAI::Graders::PythonGrader }
  28. # A ScoreModelGrader object that uses a model to assign a score to the input.
  29. 1 variant -> { OpenAI::Graders::ScoreModelGrader }
  30. # A MultiGrader object combines the output of multiple graders to produce a single score.
  31. 1 variant -> { OpenAI::Graders::MultiGrader }
  32. # @!method self.variants
  33. # @return [Array(OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader)]
  34. end
  35. end
  36. end
  37. end
  38. end
  39. end

openai-ruby/lib/openai/models/fine_tuning/alpha/grader_validate_response.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Alpha
  6. # @see OpenAI::Resources::FineTuning::Alpha::Graders#validate
  7. 1 class GraderValidateResponse < OpenAI::Internal::Type::BaseModel
  8. # @!attribute grader
  9. # The grader used for the fine-tuning job.
  10. #
  11. # @return [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader, nil]
  12. 1 optional :grader, union: -> { OpenAI::Models::FineTuning::Alpha::GraderValidateResponse::Grader }
  13. # @!method initialize(grader: nil)
  14. # @param grader [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader] The grader used for the fine-tuning job.
  15. # The grader used for the fine-tuning job.
  16. #
  17. # @see OpenAI::Models::FineTuning::Alpha::GraderValidateResponse#grader
  18. 1 module Grader
  19. 1 extend OpenAI::Internal::Type::Union
  20. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  21. 1 variant -> { OpenAI::Graders::StringCheckGrader }
  22. # A TextSimilarityGrader object which grades text based on similarity metrics.
  23. 1 variant -> { OpenAI::Graders::TextSimilarityGrader }
  24. # A PythonGrader object that runs a python script on the input.
  25. 1 variant -> { OpenAI::Graders::PythonGrader }
  26. # A ScoreModelGrader object that uses a model to assign a score to the input.
  27. 1 variant -> { OpenAI::Graders::ScoreModelGrader }
  28. # A MultiGrader object combines the output of multiple graders to produce a single score.
  29. 1 variant -> { OpenAI::Graders::MultiGrader }
  30. # @!method self.variants
  31. # @return [Array(OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader)]
  32. end
  33. end
  34. end
  35. end
  36. end
  37. end

openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_create_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Checkpoints
  6. # @see OpenAI::Resources::FineTuning::Checkpoints::Permissions#create
  7. 1 class PermissionCreateParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute project_ids
  11. # The project identifiers to grant access to.
  12. #
  13. # @return [Array<String>]
  14. 1 required :project_ids, OpenAI::Internal::Type::ArrayOf[String]
  15. # @!method initialize(project_ids:, request_options: {})
  16. # @param project_ids [Array<String>] The project identifiers to grant access to.
  17. #
  18. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  19. end
  20. end
  21. end
  22. end
  23. end

openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_create_response.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Checkpoints
  6. # @see OpenAI::Resources::FineTuning::Checkpoints::Permissions#create
  7. 1 class PermissionCreateResponse < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # The permission identifier, which can be referenced in the API endpoints.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute created_at
  14. # The Unix timestamp (in seconds) for when the permission was created.
  15. #
  16. # @return [Integer]
  17. 1 required :created_at, Integer
  18. # @!attribute object
  19. # The object type, which is always "checkpoint.permission".
  20. #
  21. # @return [Symbol, :"checkpoint.permission"]
  22. 1 required :object, const: :"checkpoint.permission"
  23. # @!attribute project_id
  24. # The project identifier that the permission is for.
  25. #
  26. # @return [String]
  27. 1 required :project_id, String
  28. # @!method initialize(id:, created_at:, project_id:, object: :"checkpoint.permission")
  29. # The `checkpoint.permission` object represents a permission for a fine-tuned
  30. # model checkpoint.
  31. #
  32. # @param id [String] The permission identifier, which can be referenced in the API endpoints.
  33. #
  34. # @param created_at [Integer] The Unix timestamp (in seconds) for when the permission was created.
  35. #
  36. # @param project_id [String] The project identifier that the permission is for.
  37. #
  38. # @param object [Symbol, :"checkpoint.permission"] The object type, which is always "checkpoint.permission".
  39. end
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_delete_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Checkpoints
  6. # @see OpenAI::Resources::FineTuning::Checkpoints::Permissions#delete
  7. 1 class PermissionDeleteParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute fine_tuned_model_checkpoint
  11. #
  12. # @return [String]
  13. 1 required :fine_tuned_model_checkpoint, String
  14. # @!method initialize(fine_tuned_model_checkpoint:, request_options: {})
  15. # @param fine_tuned_model_checkpoint [String]
  16. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  17. end
  18. end
  19. end
  20. end
  21. end

openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_delete_response.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Checkpoints
  6. # @see OpenAI::Resources::FineTuning::Checkpoints::Permissions#delete
  7. 1 class PermissionDeleteResponse < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # The ID of the fine-tuned model checkpoint permission that was deleted.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute deleted
  14. # Whether the fine-tuned model checkpoint permission was successfully deleted.
  15. #
  16. # @return [Boolean]
  17. 1 required :deleted, OpenAI::Internal::Type::Boolean
  18. # @!attribute object
  19. # The object type, which is always "checkpoint.permission".
  20. #
  21. # @return [Symbol, :"checkpoint.permission"]
  22. 1 required :object, const: :"checkpoint.permission"
  23. # @!method initialize(id:, deleted:, object: :"checkpoint.permission")
  24. # @param id [String] The ID of the fine-tuned model checkpoint permission that was deleted.
  25. #
  26. # @param deleted [Boolean] Whether the fine-tuned model checkpoint permission was successfully deleted.
  27. #
  28. # @param object [Symbol, :"checkpoint.permission"] The object type, which is always "checkpoint.permission".
  29. end
  30. end
  31. end
  32. end
  33. end

openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_retrieve_params.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Checkpoints
  6. # @see OpenAI::Resources::FineTuning::Checkpoints::Permissions#retrieve
  7. 1 class PermissionRetrieveParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute after
  11. # Identifier for the last permission ID from the previous pagination request.
  12. #
  13. # @return [String, nil]
  14. 1 optional :after, String
  15. # @!attribute limit
  16. # Number of permissions to retrieve.
  17. #
  18. # @return [Integer, nil]
  19. 1 optional :limit, Integer
  20. # @!attribute order
  21. # The order in which to retrieve permissions.
  22. #
  23. # @return [Symbol, OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveParams::Order, nil]
  24. 1 optional :order, enum: -> { OpenAI::FineTuning::Checkpoints::PermissionRetrieveParams::Order }
  25. # @!attribute project_id
  26. # The ID of the project to get permissions for.
  27. #
  28. # @return [String, nil]
  29. 1 optional :project_id, String
  30. # @!method initialize(after: nil, limit: nil, order: nil, project_id: nil, request_options: {})
  31. # @param after [String] Identifier for the last permission ID from the previous pagination request.
  32. #
  33. # @param limit [Integer] Number of permissions to retrieve.
  34. #
  35. # @param order [Symbol, OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveParams::Order] The order in which to retrieve permissions.
  36. #
  37. # @param project_id [String] The ID of the project to get permissions for.
  38. #
  39. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  40. # The order in which to retrieve permissions.
  41. 1 module Order
  42. 1 extend OpenAI::Internal::Type::Enum
  43. 1 ASCENDING = :ascending
  44. 1 DESCENDING = :descending
  45. # @!method self.values
  46. # @return [Array<Symbol>]
  47. end
  48. end
  49. end
  50. end
  51. end
  52. end

openai-ruby/lib/openai/models/fine_tuning/checkpoints/permission_retrieve_response.rb

93.75% lines covered

100.0% branches covered

16 relevant lines. 15 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Checkpoints
  6. # @see OpenAI::Resources::FineTuning::Checkpoints::Permissions#retrieve
  7. 1 class PermissionRetrieveResponse < OpenAI::Internal::Type::BaseModel
  8. # @!attribute data
  9. #
  10. # @return [Array<OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveResponse::Data>]
  11. 1 required :data,
  12. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveResponse::Data] }
  13. # @!attribute has_more
  14. #
  15. # @return [Boolean]
  16. 1 required :has_more, OpenAI::Internal::Type::Boolean
  17. # @!attribute object
  18. #
  19. # @return [Symbol, :list]
  20. 1 required :object, const: :list
  21. # @!attribute first_id
  22. #
  23. # @return [String, nil]
  24. 1 optional :first_id, String, nil?: true
  25. # @!attribute last_id
  26. #
  27. # @return [String, nil]
  28. 1 optional :last_id, String, nil?: true
  29. # @!method initialize(data:, has_more:, first_id: nil, last_id: nil, object: :list)
  30. # @param data [Array<OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveResponse::Data>]
  31. # @param has_more [Boolean]
  32. # @param first_id [String, nil]
  33. # @param last_id [String, nil]
  34. # @param object [Symbol, :list]
  35. 1 class Data < OpenAI::Internal::Type::BaseModel
  36. # @!attribute id
  37. # The permission identifier, which can be referenced in the API endpoints.
  38. #
  39. # @return [String]
  40. 1 required :id, String
  41. # @!attribute created_at
  42. # The Unix timestamp (in seconds) for when the permission was created.
  43. #
  44. # @return [Integer]
  45. 1 required :created_at, Integer
  46. # @!attribute object
  47. # The object type, which is always "checkpoint.permission".
  48. #
  49. # @return [Symbol, :"checkpoint.permission"]
  50. 1 required :object, const: :"checkpoint.permission"
  51. # @!attribute project_id
  52. # The project identifier that the permission is for.
  53. #
  54. # @return [String]
  55. 1 required :project_id, String
  56. # @!method initialize(id:, created_at:, project_id:, object: :"checkpoint.permission")
  57. # The `checkpoint.permission` object represents a permission for a fine-tuned
  58. # model checkpoint.
  59. #
  60. # @param id [String] The permission identifier, which can be referenced in the API endpoints.
  61. #
  62. # @param created_at [Integer] The Unix timestamp (in seconds) for when the permission was created.
  63. #
  64. # @param project_id [String] The project identifier that the permission is for.
  65. #
  66. # @param object [Symbol, :"checkpoint.permission"] The object type, which is always "checkpoint.permission".
  67. end
  68. end
  69. end
  70. end
  71. end
  72. end

openai-ruby/lib/openai/models/fine_tuning/dpo_hyperparameters.rb

96.0% lines covered

100.0% branches covered

25 relevant lines. 24 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 class DpoHyperparameters < OpenAI::Internal::Type::BaseModel
  6. # @!attribute batch_size
  7. # Number of examples in each batch. A larger batch size means that model
  8. # parameters are updated less frequently, but with lower variance.
  9. #
  10. # @return [Symbol, :auto, Integer, nil]
  11. 1 optional :batch_size, union: -> { OpenAI::FineTuning::DpoHyperparameters::BatchSize }
  12. # @!attribute beta
  13. # The beta value for the DPO method. A higher beta value will increase the weight
  14. # of the penalty between the policy and reference model.
  15. #
  16. # @return [Symbol, :auto, Float, nil]
  17. 1 optional :beta, union: -> { OpenAI::FineTuning::DpoHyperparameters::Beta }
  18. # @!attribute learning_rate_multiplier
  19. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  20. # avoid overfitting.
  21. #
  22. # @return [Symbol, :auto, Float, nil]
  23. 1 optional :learning_rate_multiplier,
  24. union: -> { OpenAI::FineTuning::DpoHyperparameters::LearningRateMultiplier }
  25. # @!attribute n_epochs
  26. # The number of epochs to train the model for. An epoch refers to one full cycle
  27. # through the training dataset.
  28. #
  29. # @return [Symbol, :auto, Integer, nil]
  30. 1 optional :n_epochs, union: -> { OpenAI::FineTuning::DpoHyperparameters::NEpochs }
  31. # @!method initialize(batch_size: nil, beta: nil, learning_rate_multiplier: nil, n_epochs: nil)
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::FineTuning::DpoHyperparameters} for more details.
  34. #
  35. # The hyperparameters used for the DPO fine-tuning job.
  36. #
  37. # @param batch_size [Symbol, :auto, Integer] Number of examples in each batch. A larger batch size means that model parameter
  38. #
  39. # @param beta [Symbol, :auto, Float] The beta value for the DPO method. A higher beta value will increase the weight
  40. #
  41. # @param learning_rate_multiplier [Symbol, :auto, Float] Scaling factor for the learning rate. A smaller learning rate may be useful to a
  42. #
  43. # @param n_epochs [Symbol, :auto, Integer] The number of epochs to train the model for. An epoch refers to one full cycle t
  44. # Number of examples in each batch. A larger batch size means that model
  45. # parameters are updated less frequently, but with lower variance.
  46. #
  47. # @see OpenAI::Models::FineTuning::DpoHyperparameters#batch_size
  48. 1 module BatchSize
  49. 1 extend OpenAI::Internal::Type::Union
  50. 1 variant const: :auto
  51. 1 variant Integer
  52. # @!method self.variants
  53. # @return [Array(Symbol, :auto, Integer)]
  54. end
  55. # The beta value for the DPO method. A higher beta value will increase the weight
  56. # of the penalty between the policy and reference model.
  57. #
  58. # @see OpenAI::Models::FineTuning::DpoHyperparameters#beta
  59. 1 module Beta
  60. 1 extend OpenAI::Internal::Type::Union
  61. 1 variant const: :auto
  62. 1 variant Float
  63. # @!method self.variants
  64. # @return [Array(Symbol, :auto, Float)]
  65. end
  66. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  67. # avoid overfitting.
  68. #
  69. # @see OpenAI::Models::FineTuning::DpoHyperparameters#learning_rate_multiplier
  70. 1 module LearningRateMultiplier
  71. 1 extend OpenAI::Internal::Type::Union
  72. 1 variant const: :auto
  73. 1 variant Float
  74. # @!method self.variants
  75. # @return [Array(Symbol, :auto, Float)]
  76. end
  77. # The number of epochs to train the model for. An epoch refers to one full cycle
  78. # through the training dataset.
  79. #
  80. # @see OpenAI::Models::FineTuning::DpoHyperparameters#n_epochs
  81. 1 module NEpochs
  82. 1 extend OpenAI::Internal::Type::Union
  83. 1 variant const: :auto
  84. 1 variant Integer
  85. # @!method self.variants
  86. # @return [Array(Symbol, :auto, Integer)]
  87. end
  88. end
  89. end
  90. end
  91. end

openai-ruby/lib/openai/models/fine_tuning/dpo_method.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 class DpoMethod < OpenAI::Internal::Type::BaseModel
  6. # @!attribute hyperparameters
  7. # The hyperparameters used for the DPO fine-tuning job.
  8. #
  9. # @return [OpenAI::Models::FineTuning::DpoHyperparameters, nil]
  10. 1 optional :hyperparameters, -> { OpenAI::FineTuning::DpoHyperparameters }
  11. # @!method initialize(hyperparameters: nil)
  12. # Configuration for the DPO fine-tuning method.
  13. #
  14. # @param hyperparameters [OpenAI::Models::FineTuning::DpoHyperparameters] The hyperparameters used for the DPO fine-tuning job.
  15. end
  16. end
  17. end
  18. end

openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job.rb

95.38% lines covered

100.0% branches covered

65 relevant lines. 62 lines covered and 3 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. # @see OpenAI::Resources::FineTuning::Jobs#create
  6. 1 class FineTuningJob < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The object identifier, which can be referenced in the API endpoints.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # The Unix timestamp (in seconds) for when the fine-tuning job was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute error
  18. # For fine-tuning jobs that have `failed`, this will contain more information on
  19. # the cause of the failure.
  20. #
  21. # @return [OpenAI::Models::FineTuning::FineTuningJob::Error, nil]
  22. 1 required :error, -> { OpenAI::FineTuning::FineTuningJob::Error }, nil?: true
  23. # @!attribute fine_tuned_model
  24. # The name of the fine-tuned model that is being created. The value will be null
  25. # if the fine-tuning job is still running.
  26. #
  27. # @return [String, nil]
  28. 1 required :fine_tuned_model, String, nil?: true
  29. # @!attribute finished_at
  30. # The Unix timestamp (in seconds) for when the fine-tuning job was finished. The
  31. # value will be null if the fine-tuning job is still running.
  32. #
  33. # @return [Integer, nil]
  34. 1 required :finished_at, Integer, nil?: true
  35. # @!attribute hyperparameters
  36. # The hyperparameters used for the fine-tuning job. This value will only be
  37. # returned when running `supervised` jobs.
  38. #
  39. # @return [OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters]
  40. 1 required :hyperparameters, -> { OpenAI::FineTuning::FineTuningJob::Hyperparameters }
  41. # @!attribute model
  42. # The base model that is being fine-tuned.
  43. #
  44. # @return [String]
  45. 1 required :model, String
  46. # @!attribute object
  47. # The object type, which is always "fine_tuning.job".
  48. #
  49. # @return [Symbol, :"fine_tuning.job"]
  50. 1 required :object, const: :"fine_tuning.job"
  51. # @!attribute organization_id
  52. # The organization that owns the fine-tuning job.
  53. #
  54. # @return [String]
  55. 1 required :organization_id, String
  56. # @!attribute result_files
  57. # The compiled results file ID(s) for the fine-tuning job. You can retrieve the
  58. # results with the
  59. # [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
  60. #
  61. # @return [Array<String>]
  62. 1 required :result_files, OpenAI::Internal::Type::ArrayOf[String]
  63. # @!attribute seed
  64. # The seed used for the fine-tuning job.
  65. #
  66. # @return [Integer]
  67. 1 required :seed, Integer
  68. # @!attribute status
  69. # The current status of the fine-tuning job, which can be either
  70. # `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
  71. #
  72. # @return [Symbol, OpenAI::Models::FineTuning::FineTuningJob::Status]
  73. 1 required :status, enum: -> { OpenAI::FineTuning::FineTuningJob::Status }
  74. # @!attribute trained_tokens
  75. # The total number of billable tokens processed by this fine-tuning job. The value
  76. # will be null if the fine-tuning job is still running.
  77. #
  78. # @return [Integer, nil]
  79. 1 required :trained_tokens, Integer, nil?: true
  80. # @!attribute training_file
  81. # The file ID used for training. You can retrieve the training data with the
  82. # [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
  83. #
  84. # @return [String]
  85. 1 required :training_file, String
  86. # @!attribute validation_file
  87. # The file ID used for validation. You can retrieve the validation results with
  88. # the
  89. # [Files API](https://platform.openai.com/docs/api-reference/files/retrieve-contents).
  90. #
  91. # @return [String, nil]
  92. 1 required :validation_file, String, nil?: true
  93. # @!attribute estimated_finish
  94. # The Unix timestamp (in seconds) for when the fine-tuning job is estimated to
  95. # finish. The value will be null if the fine-tuning job is not running.
  96. #
  97. # @return [Integer, nil]
  98. 1 optional :estimated_finish, Integer, nil?: true
  99. # @!attribute integrations
  100. # A list of integrations to enable for this fine-tuning job.
  101. #
  102. # @return [Array<OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject>, nil]
  103. 1 optional :integrations,
  104. -> {
  105. OpenAI::Internal::Type::ArrayOf[OpenAI::FineTuning::FineTuningJobWandbIntegrationObject]
  106. },
  107. nil?: true
  108. # @!attribute metadata
  109. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  110. # for storing additional information about the object in a structured format, and
  111. # querying for objects via API or the dashboard.
  112. #
  113. # Keys are strings with a maximum length of 64 characters. Values are strings with
  114. # a maximum length of 512 characters.
  115. #
  116. # @return [Hash{Symbol=>String}, nil]
  117. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  118. # @!attribute method_
  119. # The method used for fine-tuning.
  120. #
  121. # @return [OpenAI::Models::FineTuning::FineTuningJob::Method, nil]
  122. 1 optional :method_, -> { OpenAI::FineTuning::FineTuningJob::Method }, api_name: :method
  123. # @!method initialize(id:, created_at:, error:, fine_tuned_model:, finished_at:, hyperparameters:, model:, organization_id:, result_files:, seed:, status:, trained_tokens:, training_file:, validation_file:, estimated_finish: nil, integrations: nil, metadata: nil, method_: nil, object: :"fine_tuning.job")
  124. # Some parameter documentations has been truncated, see
  125. # {OpenAI::Models::FineTuning::FineTuningJob} for more details.
  126. #
  127. # The `fine_tuning.job` object represents a fine-tuning job that has been created
  128. # through the API.
  129. #
  130. # @param id [String] The object identifier, which can be referenced in the API endpoints.
  131. #
  132. # @param created_at [Integer] The Unix timestamp (in seconds) for when the fine-tuning job was created.
  133. #
  134. # @param error [OpenAI::Models::FineTuning::FineTuningJob::Error, nil] For fine-tuning jobs that have `failed`, this will contain more information on t
  135. #
  136. # @param fine_tuned_model [String, nil] The name of the fine-tuned model that is being created. The value will be null i
  137. #
  138. # @param finished_at [Integer, nil] The Unix timestamp (in seconds) for when the fine-tuning job was finished. The v
  139. #
  140. # @param hyperparameters [OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters] The hyperparameters used for the fine-tuning job. This value will only be return
  141. #
  142. # @param model [String] The base model that is being fine-tuned.
  143. #
  144. # @param organization_id [String] The organization that owns the fine-tuning job.
  145. #
  146. # @param result_files [Array<String>] The compiled results file ID(s) for the fine-tuning job. You can retrieve the re
  147. #
  148. # @param seed [Integer] The seed used for the fine-tuning job.
  149. #
  150. # @param status [Symbol, OpenAI::Models::FineTuning::FineTuningJob::Status] The current status of the fine-tuning job, which can be either `validating_files
  151. #
  152. # @param trained_tokens [Integer, nil] The total number of billable tokens processed by this fine-tuning job. The value
  153. #
  154. # @param training_file [String] The file ID used for training. You can retrieve the training data with the [File
  155. #
  156. # @param validation_file [String, nil] The file ID used for validation. You can retrieve the validation results with th
  157. #
  158. # @param estimated_finish [Integer, nil] The Unix timestamp (in seconds) for when the fine-tuning job is estimated to fin
  159. #
  160. # @param integrations [Array<OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject>, nil] A list of integrations to enable for this fine-tuning job.
  161. #
  162. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  163. #
  164. # @param method_ [OpenAI::Models::FineTuning::FineTuningJob::Method] The method used for fine-tuning.
  165. #
  166. # @param object [Symbol, :"fine_tuning.job"] The object type, which is always "fine_tuning.job".
  167. # @see OpenAI::Models::FineTuning::FineTuningJob#error
  168. 1 class Error < OpenAI::Internal::Type::BaseModel
  169. # @!attribute code
  170. # A machine-readable error code.
  171. #
  172. # @return [String]
  173. 1 required :code, String
  174. # @!attribute message
  175. # A human-readable error message.
  176. #
  177. # @return [String]
  178. 1 required :message, String
  179. # @!attribute param
  180. # The parameter that was invalid, usually `training_file` or `validation_file`.
  181. # This field will be null if the failure was not parameter-specific.
  182. #
  183. # @return [String, nil]
  184. 1 required :param, String, nil?: true
  185. # @!method initialize(code:, message:, param:)
  186. # Some parameter documentations has been truncated, see
  187. # {OpenAI::Models::FineTuning::FineTuningJob::Error} for more details.
  188. #
  189. # For fine-tuning jobs that have `failed`, this will contain more information on
  190. # the cause of the failure.
  191. #
  192. # @param code [String] A machine-readable error code.
  193. #
  194. # @param message [String] A human-readable error message.
  195. #
  196. # @param param [String, nil] The parameter that was invalid, usually `training_file` or `validation_file`. Th
  197. end
  198. # @see OpenAI::Models::FineTuning::FineTuningJob#hyperparameters
  199. 1 class Hyperparameters < OpenAI::Internal::Type::BaseModel
  200. # @!attribute batch_size
  201. # Number of examples in each batch. A larger batch size means that model
  202. # parameters are updated less frequently, but with lower variance.
  203. #
  204. # @return [Symbol, :auto, Integer, nil]
  205. 1 optional :batch_size,
  206. union: -> { OpenAI::FineTuning::FineTuningJob::Hyperparameters::BatchSize },
  207. nil?: true
  208. # @!attribute learning_rate_multiplier
  209. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  210. # avoid overfitting.
  211. #
  212. # @return [Symbol, :auto, Float, nil]
  213. 1 optional :learning_rate_multiplier,
  214. union: -> { OpenAI::FineTuning::FineTuningJob::Hyperparameters::LearningRateMultiplier }
  215. # @!attribute n_epochs
  216. # The number of epochs to train the model for. An epoch refers to one full cycle
  217. # through the training dataset.
  218. #
  219. # @return [Symbol, :auto, Integer, nil]
  220. 1 optional :n_epochs, union: -> { OpenAI::FineTuning::FineTuningJob::Hyperparameters::NEpochs }
  221. # @!method initialize(batch_size: nil, learning_rate_multiplier: nil, n_epochs: nil)
  222. # Some parameter documentations has been truncated, see
  223. # {OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters} for more details.
  224. #
  225. # The hyperparameters used for the fine-tuning job. This value will only be
  226. # returned when running `supervised` jobs.
  227. #
  228. # @param batch_size [Symbol, :auto, Integer, nil] Number of examples in each batch. A larger batch size means that model parameter
  229. #
  230. # @param learning_rate_multiplier [Symbol, :auto, Float] Scaling factor for the learning rate. A smaller learning rate may be useful to a
  231. #
  232. # @param n_epochs [Symbol, :auto, Integer] The number of epochs to train the model for. An epoch refers to one full cycle
  233. # Number of examples in each batch. A larger batch size means that model
  234. # parameters are updated less frequently, but with lower variance.
  235. #
  236. # @see OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters#batch_size
  237. 1 module BatchSize
  238. 1 extend OpenAI::Internal::Type::Union
  239. 1 variant const: :auto
  240. 1 variant Integer
  241. # @!method self.variants
  242. # @return [Array(Symbol, :auto, Integer)]
  243. end
  244. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  245. # avoid overfitting.
  246. #
  247. # @see OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters#learning_rate_multiplier
  248. 1 module LearningRateMultiplier
  249. 1 extend OpenAI::Internal::Type::Union
  250. 1 variant const: :auto
  251. 1 variant Float
  252. # @!method self.variants
  253. # @return [Array(Symbol, :auto, Float)]
  254. end
  255. # The number of epochs to train the model for. An epoch refers to one full cycle
  256. # through the training dataset.
  257. #
  258. # @see OpenAI::Models::FineTuning::FineTuningJob::Hyperparameters#n_epochs
  259. 1 module NEpochs
  260. 1 extend OpenAI::Internal::Type::Union
  261. 1 variant const: :auto
  262. 1 variant Integer
  263. # @!method self.variants
  264. # @return [Array(Symbol, :auto, Integer)]
  265. end
  266. end
  267. # The current status of the fine-tuning job, which can be either
  268. # `validating_files`, `queued`, `running`, `succeeded`, `failed`, or `cancelled`.
  269. #
  270. # @see OpenAI::Models::FineTuning::FineTuningJob#status
  271. 1 module Status
  272. 1 extend OpenAI::Internal::Type::Enum
  273. 1 VALIDATING_FILES = :validating_files
  274. 1 QUEUED = :queued
  275. 1 RUNNING = :running
  276. 1 SUCCEEDED = :succeeded
  277. 1 FAILED = :failed
  278. 1 CANCELLED = :cancelled
  279. # @!method self.values
  280. # @return [Array<Symbol>]
  281. end
  282. # @see OpenAI::Models::FineTuning::FineTuningJob#method_
  283. 1 class Method < OpenAI::Internal::Type::BaseModel
  284. # @!attribute type
  285. # The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
  286. #
  287. # @return [Symbol, OpenAI::Models::FineTuning::FineTuningJob::Method::Type]
  288. 1 required :type, enum: -> { OpenAI::FineTuning::FineTuningJob::Method::Type }
  289. # @!attribute dpo
  290. # Configuration for the DPO fine-tuning method.
  291. #
  292. # @return [OpenAI::Models::FineTuning::DpoMethod, nil]
  293. 1 optional :dpo, -> { OpenAI::FineTuning::DpoMethod }
  294. # @!attribute reinforcement
  295. # Configuration for the reinforcement fine-tuning method.
  296. #
  297. # @return [OpenAI::Models::FineTuning::ReinforcementMethod, nil]
  298. 1 optional :reinforcement, -> { OpenAI::FineTuning::ReinforcementMethod }
  299. # @!attribute supervised
  300. # Configuration for the supervised fine-tuning method.
  301. #
  302. # @return [OpenAI::Models::FineTuning::SupervisedMethod, nil]
  303. 1 optional :supervised, -> { OpenAI::FineTuning::SupervisedMethod }
  304. # @!method initialize(type:, dpo: nil, reinforcement: nil, supervised: nil)
  305. # The method used for fine-tuning.
  306. #
  307. # @param type [Symbol, OpenAI::Models::FineTuning::FineTuningJob::Method::Type] The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
  308. #
  309. # @param dpo [OpenAI::Models::FineTuning::DpoMethod] Configuration for the DPO fine-tuning method.
  310. #
  311. # @param reinforcement [OpenAI::Models::FineTuning::ReinforcementMethod] Configuration for the reinforcement fine-tuning method.
  312. #
  313. # @param supervised [OpenAI::Models::FineTuning::SupervisedMethod] Configuration for the supervised fine-tuning method.
  314. # The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
  315. #
  316. # @see OpenAI::Models::FineTuning::FineTuningJob::Method#type
  317. 1 module Type
  318. 1 extend OpenAI::Internal::Type::Enum
  319. 1 SUPERVISED = :supervised
  320. 1 DPO = :dpo
  321. 1 REINFORCEMENT = :reinforcement
  322. # @!method self.values
  323. # @return [Array<Symbol>]
  324. end
  325. end
  326. end
  327. end
  328. 1 FineTuningJob = FineTuning::FineTuningJob
  329. end
  330. end

openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job_event.rb

100.0% lines covered

100.0% branches covered

21 relevant lines. 21 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. # @see OpenAI::Resources::FineTuning::Jobs#list_events
  6. 1 class FineTuningJobEvent < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The object identifier.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # The Unix timestamp (in seconds) for when the fine-tuning job was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute level
  18. # The log level of the event.
  19. #
  20. # @return [Symbol, OpenAI::Models::FineTuning::FineTuningJobEvent::Level]
  21. 1 required :level, enum: -> { OpenAI::FineTuning::FineTuningJobEvent::Level }
  22. # @!attribute message
  23. # The message of the event.
  24. #
  25. # @return [String]
  26. 1 required :message, String
  27. # @!attribute object
  28. # The object type, which is always "fine_tuning.job.event".
  29. #
  30. # @return [Symbol, :"fine_tuning.job.event"]
  31. 1 required :object, const: :"fine_tuning.job.event"
  32. # @!attribute data
  33. # The data associated with the event.
  34. #
  35. # @return [Object, nil]
  36. 1 optional :data, OpenAI::Internal::Type::Unknown
  37. # @!attribute type
  38. # The type of event.
  39. #
  40. # @return [Symbol, OpenAI::Models::FineTuning::FineTuningJobEvent::Type, nil]
  41. 1 optional :type, enum: -> { OpenAI::FineTuning::FineTuningJobEvent::Type }
  42. # @!method initialize(id:, created_at:, level:, message:, data: nil, type: nil, object: :"fine_tuning.job.event")
  43. # Fine-tuning job event object
  44. #
  45. # @param id [String] The object identifier.
  46. #
  47. # @param created_at [Integer] The Unix timestamp (in seconds) for when the fine-tuning job was created.
  48. #
  49. # @param level [Symbol, OpenAI::Models::FineTuning::FineTuningJobEvent::Level] The log level of the event.
  50. #
  51. # @param message [String] The message of the event.
  52. #
  53. # @param data [Object] The data associated with the event.
  54. #
  55. # @param type [Symbol, OpenAI::Models::FineTuning::FineTuningJobEvent::Type] The type of event.
  56. #
  57. # @param object [Symbol, :"fine_tuning.job.event"] The object type, which is always "fine_tuning.job.event".
  58. # The log level of the event.
  59. #
  60. # @see OpenAI::Models::FineTuning::FineTuningJobEvent#level
  61. 1 module Level
  62. 1 extend OpenAI::Internal::Type::Enum
  63. 1 INFO = :info
  64. 1 WARN = :warn
  65. 1 ERROR = :error
  66. # @!method self.values
  67. # @return [Array<Symbol>]
  68. end
  69. # The type of event.
  70. #
  71. # @see OpenAI::Models::FineTuning::FineTuningJobEvent#type
  72. 1 module Type
  73. 1 extend OpenAI::Internal::Type::Enum
  74. 1 MESSAGE = :message
  75. 1 METRICS = :metrics
  76. # @!method self.values
  77. # @return [Array<Symbol>]
  78. end
  79. end
  80. end
  81. 1 FineTuningJobEvent = FineTuning::FineTuningJobEvent
  82. end
  83. end

openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job_integration.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 FineTuningJobIntegration = OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject
  6. end
  7. 1 FineTuningJobIntegration = FineTuning::FineTuningJobIntegration
  8. end
  9. end

openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 class FineTuningJobWandbIntegration < OpenAI::Internal::Type::BaseModel
  6. # @!attribute project
  7. # The name of the project that the new run will be created under.
  8. #
  9. # @return [String]
  10. 1 required :project, String
  11. # @!attribute entity
  12. # The entity to use for the run. This allows you to set the team or username of
  13. # the WandB user that you would like associated with the run. If not set, the
  14. # default entity for the registered WandB API key is used.
  15. #
  16. # @return [String, nil]
  17. 1 optional :entity, String, nil?: true
  18. # @!attribute name
  19. # A display name to set for the run. If not set, we will use the Job ID as the
  20. # name.
  21. #
  22. # @return [String, nil]
  23. 1 optional :name, String, nil?: true
  24. # @!attribute tags
  25. # A list of tags to be attached to the newly created run. These tags are passed
  26. # through directly to WandB. Some default tags are generated by OpenAI:
  27. # "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}".
  28. #
  29. # @return [Array<String>, nil]
  30. 1 optional :tags, OpenAI::Internal::Type::ArrayOf[String]
  31. # @!method initialize(project:, entity: nil, name: nil, tags: nil)
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::FineTuning::FineTuningJobWandbIntegration} for more details.
  34. #
  35. # The settings for your integration with Weights and Biases. This payload
  36. # specifies the project that metrics will be sent to. Optionally, you can set an
  37. # explicit display name for your run, add tags to your run, and set a default
  38. # entity (team, username, etc) to be associated with your run.
  39. #
  40. # @param project [String] The name of the project that the new run will be created under.
  41. #
  42. # @param entity [String, nil] The entity to use for the run. This allows you to set the team or username of th
  43. #
  44. # @param name [String, nil] A display name to set for the run. If not set, we will use the Job ID as the nam
  45. #
  46. # @param tags [Array<String>] A list of tags to be attached to the newly created run. These tags are passed th
  47. end
  48. end
  49. 1 FineTuningJobWandbIntegration = FineTuning::FineTuningJobWandbIntegration
  50. end
  51. end

openai-ruby/lib/openai/models/fine_tuning/fine_tuning_job_wandb_integration_object.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 class FineTuningJobWandbIntegrationObject < OpenAI::Internal::Type::BaseModel
  6. # @!attribute type
  7. # The type of the integration being enabled for the fine-tuning job
  8. #
  9. # @return [Symbol, :wandb]
  10. 1 required :type, const: :wandb
  11. # @!attribute wandb
  12. # The settings for your integration with Weights and Biases. This payload
  13. # specifies the project that metrics will be sent to. Optionally, you can set an
  14. # explicit display name for your run, add tags to your run, and set a default
  15. # entity (team, username, etc) to be associated with your run.
  16. #
  17. # @return [OpenAI::Models::FineTuning::FineTuningJobWandbIntegration]
  18. 1 required :wandb, -> { OpenAI::FineTuning::FineTuningJobWandbIntegration }
  19. # @!method initialize(wandb:, type: :wandb)
  20. # Some parameter documentations has been truncated, see
  21. # {OpenAI::Models::FineTuning::FineTuningJobWandbIntegrationObject} for more
  22. # details.
  23. #
  24. # @param wandb [OpenAI::Models::FineTuning::FineTuningJobWandbIntegration] The settings for your integration with Weights and Biases. This payload specifie
  25. #
  26. # @param type [Symbol, :wandb] The type of the integration being enabled for the fine-tuning job
  27. end
  28. end
  29. 1 FineTuningJobWandbIntegrationObject = FineTuning::FineTuningJobWandbIntegrationObject
  30. end
  31. end

openai-ruby/lib/openai/models/fine_tuning/job_cancel_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. # @see OpenAI::Resources::FineTuning::Jobs#cancel
  6. 1 class JobCancelParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/fine_tuning/job_create_params.rb

95.31% lines covered

100.0% branches covered

64 relevant lines. 61 lines covered and 3 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. # @see OpenAI::Resources::FineTuning::Jobs#create
  6. 1 class JobCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute model
  10. # The name of the model to fine-tune. You can select one of the
  11. # [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned).
  12. #
  13. # @return [String, Symbol, OpenAI::Models::FineTuning::JobCreateParams::Model]
  14. 1 required :model, union: -> { OpenAI::FineTuning::JobCreateParams::Model }
  15. # @!attribute training_file
  16. # The ID of an uploaded file that contains training data.
  17. #
  18. # See [upload file](https://platform.openai.com/docs/api-reference/files/create)
  19. # for how to upload a file.
  20. #
  21. # Your dataset must be formatted as a JSONL file. Additionally, you must upload
  22. # your file with the purpose `fine-tune`.
  23. #
  24. # The contents of the file should differ depending on if the model uses the
  25. # [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input),
  26. # [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
  27. # format, or if the fine-tuning method uses the
  28. # [preference](https://platform.openai.com/docs/api-reference/fine-tuning/preference-input)
  29. # format.
  30. #
  31. # See the
  32. # [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
  33. # for more details.
  34. #
  35. # @return [String]
  36. 1 required :training_file, String
  37. # @!attribute hyperparameters
  38. # @deprecated
  39. #
  40. # The hyperparameters used for the fine-tuning job. This value is now deprecated
  41. # in favor of `method`, and should be passed in under the `method` parameter.
  42. #
  43. # @return [OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters, nil]
  44. 1 optional :hyperparameters, -> { OpenAI::FineTuning::JobCreateParams::Hyperparameters }
  45. # @!attribute integrations
  46. # A list of integrations to enable for your fine-tuning job.
  47. #
  48. # @return [Array<OpenAI::Models::FineTuning::JobCreateParams::Integration>, nil]
  49. 1 optional :integrations,
  50. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::FineTuning::JobCreateParams::Integration] },
  51. nil?: true
  52. # @!attribute metadata
  53. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  54. # for storing additional information about the object in a structured format, and
  55. # querying for objects via API or the dashboard.
  56. #
  57. # Keys are strings with a maximum length of 64 characters. Values are strings with
  58. # a maximum length of 512 characters.
  59. #
  60. # @return [Hash{Symbol=>String}, nil]
  61. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  62. # @!attribute method_
  63. # The method used for fine-tuning.
  64. #
  65. # @return [OpenAI::Models::FineTuning::JobCreateParams::Method, nil]
  66. 1 optional :method_, -> { OpenAI::FineTuning::JobCreateParams::Method }, api_name: :method
  67. # @!attribute seed
  68. # The seed controls the reproducibility of the job. Passing in the same seed and
  69. # job parameters should produce the same results, but may differ in rare cases. If
  70. # a seed is not specified, one will be generated for you.
  71. #
  72. # @return [Integer, nil]
  73. 1 optional :seed, Integer, nil?: true
  74. # @!attribute suffix
  75. # A string of up to 64 characters that will be added to your fine-tuned model
  76. # name.
  77. #
  78. # For example, a `suffix` of "custom-model-name" would produce a model name like
  79. # `ft:gpt-4o-mini:openai:custom-model-name:7p4lURel`.
  80. #
  81. # @return [String, nil]
  82. 1 optional :suffix, String, nil?: true
  83. # @!attribute validation_file
  84. # The ID of an uploaded file that contains validation data.
  85. #
  86. # If you provide this file, the data is used to generate validation metrics
  87. # periodically during fine-tuning. These metrics can be viewed in the fine-tuning
  88. # results file. The same data should not be present in both train and validation
  89. # files.
  90. #
  91. # Your dataset must be formatted as a JSONL file. You must upload your file with
  92. # the purpose `fine-tune`.
  93. #
  94. # See the
  95. # [fine-tuning guide](https://platform.openai.com/docs/guides/model-optimization)
  96. # for more details.
  97. #
  98. # @return [String, nil]
  99. 1 optional :validation_file, String, nil?: true
  100. # @!method initialize(model:, training_file:, hyperparameters: nil, integrations: nil, metadata: nil, method_: nil, seed: nil, suffix: nil, validation_file: nil, request_options: {})
  101. # Some parameter documentations has been truncated, see
  102. # {OpenAI::Models::FineTuning::JobCreateParams} for more details.
  103. #
  104. # @param model [String, Symbol, OpenAI::Models::FineTuning::JobCreateParams::Model] The name of the model to fine-tune. You can select one of the
  105. #
  106. # @param training_file [String] The ID of an uploaded file that contains training data.
  107. #
  108. # @param hyperparameters [OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters] The hyperparameters used for the fine-tuning job.
  109. #
  110. # @param integrations [Array<OpenAI::Models::FineTuning::JobCreateParams::Integration>, nil] A list of integrations to enable for your fine-tuning job.
  111. #
  112. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  113. #
  114. # @param method_ [OpenAI::Models::FineTuning::JobCreateParams::Method] The method used for fine-tuning.
  115. #
  116. # @param seed [Integer, nil] The seed controls the reproducibility of the job. Passing in the same seed and j
  117. #
  118. # @param suffix [String, nil] A string of up to 64 characters that will be added to your fine-tuned model name
  119. #
  120. # @param validation_file [String, nil] The ID of an uploaded file that contains validation data.
  121. #
  122. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  123. # The name of the model to fine-tune. You can select one of the
  124. # [supported models](https://platform.openai.com/docs/guides/fine-tuning#which-models-can-be-fine-tuned).
  125. 1 module Model
  126. 1 extend OpenAI::Internal::Type::Union
  127. 1 variant String
  128. 1 variant const: -> { OpenAI::Models::FineTuning::JobCreateParams::Model::BABBAGE_002 }
  129. 1 variant const: -> { OpenAI::Models::FineTuning::JobCreateParams::Model::DAVINCI_002 }
  130. 1 variant const: -> { OpenAI::Models::FineTuning::JobCreateParams::Model::GPT_3_5_TURBO }
  131. 1 variant const: -> { OpenAI::Models::FineTuning::JobCreateParams::Model::GPT_4O_MINI }
  132. # @!method self.variants
  133. # @return [Array(String, Symbol)]
  134. 1 define_sorbet_constant!(:Variants) do
  135. T.type_alias { T.any(String, OpenAI::FineTuning::JobCreateParams::Model::TaggedSymbol) }
  136. end
  137. # @!group
  138. 1 BABBAGE_002 = :"babbage-002"
  139. 1 DAVINCI_002 = :"davinci-002"
  140. 1 GPT_3_5_TURBO = :"gpt-3.5-turbo"
  141. 1 GPT_4O_MINI = :"gpt-4o-mini"
  142. # @!endgroup
  143. end
  144. # @deprecated
  145. 1 class Hyperparameters < OpenAI::Internal::Type::BaseModel
  146. # @!attribute batch_size
  147. # Number of examples in each batch. A larger batch size means that model
  148. # parameters are updated less frequently, but with lower variance.
  149. #
  150. # @return [Symbol, :auto, Integer, nil]
  151. 1 optional :batch_size, union: -> { OpenAI::FineTuning::JobCreateParams::Hyperparameters::BatchSize }
  152. # @!attribute learning_rate_multiplier
  153. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  154. # avoid overfitting.
  155. #
  156. # @return [Symbol, :auto, Float, nil]
  157. 1 optional :learning_rate_multiplier,
  158. union: -> { OpenAI::FineTuning::JobCreateParams::Hyperparameters::LearningRateMultiplier }
  159. # @!attribute n_epochs
  160. # The number of epochs to train the model for. An epoch refers to one full cycle
  161. # through the training dataset.
  162. #
  163. # @return [Symbol, :auto, Integer, nil]
  164. 1 optional :n_epochs, union: -> { OpenAI::FineTuning::JobCreateParams::Hyperparameters::NEpochs }
  165. # @!method initialize(batch_size: nil, learning_rate_multiplier: nil, n_epochs: nil)
  166. # Some parameter documentations has been truncated, see
  167. # {OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters} for more details.
  168. #
  169. # The hyperparameters used for the fine-tuning job. This value is now deprecated
  170. # in favor of `method`, and should be passed in under the `method` parameter.
  171. #
  172. # @param batch_size [Symbol, :auto, Integer] Number of examples in each batch. A larger batch size means that model parameter
  173. #
  174. # @param learning_rate_multiplier [Symbol, :auto, Float] Scaling factor for the learning rate. A smaller learning rate may be useful to a
  175. #
  176. # @param n_epochs [Symbol, :auto, Integer] The number of epochs to train the model for. An epoch refers to one full cycle
  177. # Number of examples in each batch. A larger batch size means that model
  178. # parameters are updated less frequently, but with lower variance.
  179. #
  180. # @see OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters#batch_size
  181. 1 module BatchSize
  182. 1 extend OpenAI::Internal::Type::Union
  183. 1 variant const: :auto
  184. 1 variant Integer
  185. # @!method self.variants
  186. # @return [Array(Symbol, :auto, Integer)]
  187. end
  188. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  189. # avoid overfitting.
  190. #
  191. # @see OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters#learning_rate_multiplier
  192. 1 module LearningRateMultiplier
  193. 1 extend OpenAI::Internal::Type::Union
  194. 1 variant const: :auto
  195. 1 variant Float
  196. # @!method self.variants
  197. # @return [Array(Symbol, :auto, Float)]
  198. end
  199. # The number of epochs to train the model for. An epoch refers to one full cycle
  200. # through the training dataset.
  201. #
  202. # @see OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters#n_epochs
  203. 1 module NEpochs
  204. 1 extend OpenAI::Internal::Type::Union
  205. 1 variant const: :auto
  206. 1 variant Integer
  207. # @!method self.variants
  208. # @return [Array(Symbol, :auto, Integer)]
  209. end
  210. end
  211. 1 class Integration < OpenAI::Internal::Type::BaseModel
  212. # @!attribute type
  213. # The type of integration to enable. Currently, only "wandb" (Weights and Biases)
  214. # is supported.
  215. #
  216. # @return [Symbol, :wandb]
  217. 1 required :type, const: :wandb
  218. # @!attribute wandb
  219. # The settings for your integration with Weights and Biases. This payload
  220. # specifies the project that metrics will be sent to. Optionally, you can set an
  221. # explicit display name for your run, add tags to your run, and set a default
  222. # entity (team, username, etc) to be associated with your run.
  223. #
  224. # @return [OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb]
  225. 1 required :wandb, -> { OpenAI::FineTuning::JobCreateParams::Integration::Wandb }
  226. # @!method initialize(wandb:, type: :wandb)
  227. # Some parameter documentations has been truncated, see
  228. # {OpenAI::Models::FineTuning::JobCreateParams::Integration} for more details.
  229. #
  230. # @param wandb [OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb] The settings for your integration with Weights and Biases. This payload specifie
  231. #
  232. # @param type [Symbol, :wandb] The type of integration to enable. Currently, only "wandb" (Weights and Biases)
  233. # @see OpenAI::Models::FineTuning::JobCreateParams::Integration#wandb
  234. 1 class Wandb < OpenAI::Internal::Type::BaseModel
  235. # @!attribute project
  236. # The name of the project that the new run will be created under.
  237. #
  238. # @return [String]
  239. 1 required :project, String
  240. # @!attribute entity
  241. # The entity to use for the run. This allows you to set the team or username of
  242. # the WandB user that you would like associated with the run. If not set, the
  243. # default entity for the registered WandB API key is used.
  244. #
  245. # @return [String, nil]
  246. 1 optional :entity, String, nil?: true
  247. # @!attribute name
  248. # A display name to set for the run. If not set, we will use the Job ID as the
  249. # name.
  250. #
  251. # @return [String, nil]
  252. 1 optional :name, String, nil?: true
  253. # @!attribute tags
  254. # A list of tags to be attached to the newly created run. These tags are passed
  255. # through directly to WandB. Some default tags are generated by OpenAI:
  256. # "openai/finetune", "openai/{base-model}", "openai/{ftjob-abcdef}".
  257. #
  258. # @return [Array<String>, nil]
  259. 1 optional :tags, OpenAI::Internal::Type::ArrayOf[String]
  260. # @!method initialize(project:, entity: nil, name: nil, tags: nil)
  261. # Some parameter documentations has been truncated, see
  262. # {OpenAI::Models::FineTuning::JobCreateParams::Integration::Wandb} for more
  263. # details.
  264. #
  265. # The settings for your integration with Weights and Biases. This payload
  266. # specifies the project that metrics will be sent to. Optionally, you can set an
  267. # explicit display name for your run, add tags to your run, and set a default
  268. # entity (team, username, etc) to be associated with your run.
  269. #
  270. # @param project [String] The name of the project that the new run will be created under.
  271. #
  272. # @param entity [String, nil] The entity to use for the run. This allows you to set the team or username of th
  273. #
  274. # @param name [String, nil] A display name to set for the run. If not set, we will use the Job ID as the nam
  275. #
  276. # @param tags [Array<String>] A list of tags to be attached to the newly created run. These tags are passed th
  277. end
  278. end
  279. 1 class Method < OpenAI::Internal::Type::BaseModel
  280. # @!attribute type
  281. # The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
  282. #
  283. # @return [Symbol, OpenAI::Models::FineTuning::JobCreateParams::Method::Type]
  284. 1 required :type, enum: -> { OpenAI::FineTuning::JobCreateParams::Method::Type }
  285. # @!attribute dpo
  286. # Configuration for the DPO fine-tuning method.
  287. #
  288. # @return [OpenAI::Models::FineTuning::DpoMethod, nil]
  289. 1 optional :dpo, -> { OpenAI::FineTuning::DpoMethod }
  290. # @!attribute reinforcement
  291. # Configuration for the reinforcement fine-tuning method.
  292. #
  293. # @return [OpenAI::Models::FineTuning::ReinforcementMethod, nil]
  294. 1 optional :reinforcement, -> { OpenAI::FineTuning::ReinforcementMethod }
  295. # @!attribute supervised
  296. # Configuration for the supervised fine-tuning method.
  297. #
  298. # @return [OpenAI::Models::FineTuning::SupervisedMethod, nil]
  299. 1 optional :supervised, -> { OpenAI::FineTuning::SupervisedMethod }
  300. # @!method initialize(type:, dpo: nil, reinforcement: nil, supervised: nil)
  301. # The method used for fine-tuning.
  302. #
  303. # @param type [Symbol, OpenAI::Models::FineTuning::JobCreateParams::Method::Type] The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
  304. #
  305. # @param dpo [OpenAI::Models::FineTuning::DpoMethod] Configuration for the DPO fine-tuning method.
  306. #
  307. # @param reinforcement [OpenAI::Models::FineTuning::ReinforcementMethod] Configuration for the reinforcement fine-tuning method.
  308. #
  309. # @param supervised [OpenAI::Models::FineTuning::SupervisedMethod] Configuration for the supervised fine-tuning method.
  310. # The type of method. Is either `supervised`, `dpo`, or `reinforcement`.
  311. #
  312. # @see OpenAI::Models::FineTuning::JobCreateParams::Method#type
  313. 1 module Type
  314. 1 extend OpenAI::Internal::Type::Enum
  315. 1 SUPERVISED = :supervised
  316. 1 DPO = :dpo
  317. 1 REINFORCEMENT = :reinforcement
  318. # @!method self.values
  319. # @return [Array<Symbol>]
  320. end
  321. end
  322. end
  323. end
  324. end
  325. end

openai-ruby/lib/openai/models/fine_tuning/job_list_events_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. # @see OpenAI::Resources::FineTuning::Jobs#list_events
  6. 1 class JobListEventsParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute after
  10. # Identifier for the last event from the previous pagination request.
  11. #
  12. # @return [String, nil]
  13. 1 optional :after, String
  14. # @!attribute limit
  15. # Number of events to retrieve.
  16. #
  17. # @return [Integer, nil]
  18. 1 optional :limit, Integer
  19. # @!method initialize(after: nil, limit: nil, request_options: {})
  20. # @param after [String] Identifier for the last event from the previous pagination request.
  21. #
  22. # @param limit [Integer] Number of events to retrieve.
  23. #
  24. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  25. end
  26. end
  27. end
  28. end

openai-ruby/lib/openai/models/fine_tuning/job_list_params.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. # @see OpenAI::Resources::FineTuning::Jobs#list
  6. 1 class JobListParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute after
  10. # Identifier for the last job from the previous pagination request.
  11. #
  12. # @return [String, nil]
  13. 1 optional :after, String
  14. # @!attribute limit
  15. # Number of fine-tuning jobs to retrieve.
  16. #
  17. # @return [Integer, nil]
  18. 1 optional :limit, Integer
  19. # @!attribute metadata
  20. # Optional metadata filter. To filter, use the syntax `metadata[k]=v`.
  21. # Alternatively, set `metadata=null` to indicate no metadata.
  22. #
  23. # @return [Hash{Symbol=>String}, nil]
  24. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  25. # @!method initialize(after: nil, limit: nil, metadata: nil, request_options: {})
  26. # Some parameter documentations has been truncated, see
  27. # {OpenAI::Models::FineTuning::JobListParams} for more details.
  28. #
  29. # @param after [String] Identifier for the last job from the previous pagination request.
  30. #
  31. # @param limit [Integer] Number of fine-tuning jobs to retrieve.
  32. #
  33. # @param metadata [Hash{Symbol=>String}, nil] Optional metadata filter. To filter, use the syntax `metadata[k]=v`. Alternative
  34. #
  35. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  36. end
  37. end
  38. end
  39. end

openai-ruby/lib/openai/models/fine_tuning/job_pause_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. # @see OpenAI::Resources::FineTuning::Jobs#pause
  6. 1 class JobPauseParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/fine_tuning/job_resume_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. # @see OpenAI::Resources::FineTuning::Jobs#resume
  6. 1 class JobResumeParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/fine_tuning/job_retrieve_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. # @see OpenAI::Resources::FineTuning::Jobs#retrieve
  6. 1 class JobRetrieveParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/fine_tuning/jobs/checkpoint_list_params.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Jobs
  6. # @see OpenAI::Resources::FineTuning::Jobs::Checkpoints#list
  7. 1 class CheckpointListParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute after
  11. # Identifier for the last checkpoint ID from the previous pagination request.
  12. #
  13. # @return [String, nil]
  14. 1 optional :after, String
  15. # @!attribute limit
  16. # Number of checkpoints to retrieve.
  17. #
  18. # @return [Integer, nil]
  19. 1 optional :limit, Integer
  20. # @!method initialize(after: nil, limit: nil, request_options: {})
  21. # @param after [String] Identifier for the last checkpoint ID from the previous pagination request.
  22. #
  23. # @param limit [Integer] Number of checkpoints to retrieve.
  24. #
  25. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  26. end
  27. end
  28. end
  29. end
  30. end

openai-ruby/lib/openai/models/fine_tuning/jobs/fine_tuning_job_checkpoint.rb

100.0% lines covered

100.0% branches covered

20 relevant lines. 20 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 module Jobs
  6. # @see OpenAI::Resources::FineTuning::Jobs::Checkpoints#list
  7. 1 class FineTuningJobCheckpoint < OpenAI::Internal::Type::BaseModel
  8. # @!attribute id
  9. # The checkpoint identifier, which can be referenced in the API endpoints.
  10. #
  11. # @return [String]
  12. 1 required :id, String
  13. # @!attribute created_at
  14. # The Unix timestamp (in seconds) for when the checkpoint was created.
  15. #
  16. # @return [Integer]
  17. 1 required :created_at, Integer
  18. # @!attribute fine_tuned_model_checkpoint
  19. # The name of the fine-tuned checkpoint model that is created.
  20. #
  21. # @return [String]
  22. 1 required :fine_tuned_model_checkpoint, String
  23. # @!attribute fine_tuning_job_id
  24. # The name of the fine-tuning job that this checkpoint was created from.
  25. #
  26. # @return [String]
  27. 1 required :fine_tuning_job_id, String
  28. # @!attribute metrics
  29. # Metrics at the step number during the fine-tuning job.
  30. #
  31. # @return [OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics]
  32. 1 required :metrics, -> { OpenAI::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics }
  33. # @!attribute object
  34. # The object type, which is always "fine_tuning.job.checkpoint".
  35. #
  36. # @return [Symbol, :"fine_tuning.job.checkpoint"]
  37. 1 required :object, const: :"fine_tuning.job.checkpoint"
  38. # @!attribute step_number
  39. # The step number that the checkpoint was created at.
  40. #
  41. # @return [Integer]
  42. 1 required :step_number, Integer
  43. # @!method initialize(id:, created_at:, fine_tuned_model_checkpoint:, fine_tuning_job_id:, metrics:, step_number:, object: :"fine_tuning.job.checkpoint")
  44. # The `fine_tuning.job.checkpoint` object represents a model checkpoint for a
  45. # fine-tuning job that is ready to use.
  46. #
  47. # @param id [String] The checkpoint identifier, which can be referenced in the API endpoints.
  48. #
  49. # @param created_at [Integer] The Unix timestamp (in seconds) for when the checkpoint was created.
  50. #
  51. # @param fine_tuned_model_checkpoint [String] The name of the fine-tuned checkpoint model that is created.
  52. #
  53. # @param fine_tuning_job_id [String] The name of the fine-tuning job that this checkpoint was created from.
  54. #
  55. # @param metrics [OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint::Metrics] Metrics at the step number during the fine-tuning job.
  56. #
  57. # @param step_number [Integer] The step number that the checkpoint was created at.
  58. #
  59. # @param object [Symbol, :"fine_tuning.job.checkpoint"] The object type, which is always "fine_tuning.job.checkpoint".
  60. # @see OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint#metrics
  61. 1 class Metrics < OpenAI::Internal::Type::BaseModel
  62. # @!attribute full_valid_loss
  63. #
  64. # @return [Float, nil]
  65. 1 optional :full_valid_loss, Float
  66. # @!attribute full_valid_mean_token_accuracy
  67. #
  68. # @return [Float, nil]
  69. 1 optional :full_valid_mean_token_accuracy, Float
  70. # @!attribute step
  71. #
  72. # @return [Float, nil]
  73. 1 optional :step, Float
  74. # @!attribute train_loss
  75. #
  76. # @return [Float, nil]
  77. 1 optional :train_loss, Float
  78. # @!attribute train_mean_token_accuracy
  79. #
  80. # @return [Float, nil]
  81. 1 optional :train_mean_token_accuracy, Float
  82. # @!attribute valid_loss
  83. #
  84. # @return [Float, nil]
  85. 1 optional :valid_loss, Float
  86. # @!attribute valid_mean_token_accuracy
  87. #
  88. # @return [Float, nil]
  89. 1 optional :valid_mean_token_accuracy, Float
  90. # @!method initialize(full_valid_loss: nil, full_valid_mean_token_accuracy: nil, step: nil, train_loss: nil, train_mean_token_accuracy: nil, valid_loss: nil, valid_mean_token_accuracy: nil)
  91. # Metrics at the step number during the fine-tuning job.
  92. #
  93. # @param full_valid_loss [Float]
  94. # @param full_valid_mean_token_accuracy [Float]
  95. # @param step [Float]
  96. # @param train_loss [Float]
  97. # @param train_mean_token_accuracy [Float]
  98. # @param valid_loss [Float]
  99. # @param valid_mean_token_accuracy [Float]
  100. end
  101. end
  102. end
  103. end
  104. end
  105. end

openai-ruby/lib/openai/models/fine_tuning/reinforcement_hyperparameters.rb

93.18% lines covered

100.0% branches covered

44 relevant lines. 41 lines covered and 3 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 class ReinforcementHyperparameters < OpenAI::Internal::Type::BaseModel
  6. # @!attribute batch_size
  7. # Number of examples in each batch. A larger batch size means that model
  8. # parameters are updated less frequently, but with lower variance.
  9. #
  10. # @return [Symbol, :auto, Integer, nil]
  11. 1 optional :batch_size, union: -> { OpenAI::FineTuning::ReinforcementHyperparameters::BatchSize }
  12. # @!attribute compute_multiplier
  13. # Multiplier on amount of compute used for exploring search space during training.
  14. #
  15. # @return [Symbol, :auto, Float, nil]
  16. 1 optional :compute_multiplier,
  17. union: -> { OpenAI::FineTuning::ReinforcementHyperparameters::ComputeMultiplier }
  18. # @!attribute eval_interval
  19. # The number of training steps between evaluation runs.
  20. #
  21. # @return [Symbol, :auto, Integer, nil]
  22. 1 optional :eval_interval, union: -> { OpenAI::FineTuning::ReinforcementHyperparameters::EvalInterval }
  23. # @!attribute eval_samples
  24. # Number of evaluation samples to generate per training step.
  25. #
  26. # @return [Symbol, :auto, Integer, nil]
  27. 1 optional :eval_samples, union: -> { OpenAI::FineTuning::ReinforcementHyperparameters::EvalSamples }
  28. # @!attribute learning_rate_multiplier
  29. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  30. # avoid overfitting.
  31. #
  32. # @return [Symbol, :auto, Float, nil]
  33. 1 optional :learning_rate_multiplier,
  34. union: -> { OpenAI::FineTuning::ReinforcementHyperparameters::LearningRateMultiplier }
  35. # @!attribute n_epochs
  36. # The number of epochs to train the model for. An epoch refers to one full cycle
  37. # through the training dataset.
  38. #
  39. # @return [Symbol, :auto, Integer, nil]
  40. 1 optional :n_epochs, union: -> { OpenAI::FineTuning::ReinforcementHyperparameters::NEpochs }
  41. # @!attribute reasoning_effort
  42. # Level of reasoning effort.
  43. #
  44. # @return [Symbol, OpenAI::Models::FineTuning::ReinforcementHyperparameters::ReasoningEffort, nil]
  45. 1 optional :reasoning_effort,
  46. enum: -> {
  47. OpenAI::FineTuning::ReinforcementHyperparameters::ReasoningEffort
  48. }
  49. # @!method initialize(batch_size: nil, compute_multiplier: nil, eval_interval: nil, eval_samples: nil, learning_rate_multiplier: nil, n_epochs: nil, reasoning_effort: nil)
  50. # Some parameter documentations has been truncated, see
  51. # {OpenAI::Models::FineTuning::ReinforcementHyperparameters} for more details.
  52. #
  53. # The hyperparameters used for the reinforcement fine-tuning job.
  54. #
  55. # @param batch_size [Symbol, :auto, Integer] Number of examples in each batch. A larger batch size means that model parameter
  56. #
  57. # @param compute_multiplier [Symbol, :auto, Float] Multiplier on amount of compute used for exploring search space during training.
  58. #
  59. # @param eval_interval [Symbol, :auto, Integer] The number of training steps between evaluation runs.
  60. #
  61. # @param eval_samples [Symbol, :auto, Integer] Number of evaluation samples to generate per training step.
  62. #
  63. # @param learning_rate_multiplier [Symbol, :auto, Float] Scaling factor for the learning rate. A smaller learning rate may be useful to a
  64. #
  65. # @param n_epochs [Symbol, :auto, Integer] The number of epochs to train the model for. An epoch refers to one full cycle t
  66. #
  67. # @param reasoning_effort [Symbol, OpenAI::Models::FineTuning::ReinforcementHyperparameters::ReasoningEffort] Level of reasoning effort.
  68. # Number of examples in each batch. A larger batch size means that model
  69. # parameters are updated less frequently, but with lower variance.
  70. #
  71. # @see OpenAI::Models::FineTuning::ReinforcementHyperparameters#batch_size
  72. 1 module BatchSize
  73. 1 extend OpenAI::Internal::Type::Union
  74. 1 variant const: :auto
  75. 1 variant Integer
  76. # @!method self.variants
  77. # @return [Array(Symbol, :auto, Integer)]
  78. end
  79. # Multiplier on amount of compute used for exploring search space during training.
  80. #
  81. # @see OpenAI::Models::FineTuning::ReinforcementHyperparameters#compute_multiplier
  82. 1 module ComputeMultiplier
  83. 1 extend OpenAI::Internal::Type::Union
  84. 1 variant const: :auto
  85. 1 variant Float
  86. # @!method self.variants
  87. # @return [Array(Symbol, :auto, Float)]
  88. end
  89. # The number of training steps between evaluation runs.
  90. #
  91. # @see OpenAI::Models::FineTuning::ReinforcementHyperparameters#eval_interval
  92. 1 module EvalInterval
  93. 1 extend OpenAI::Internal::Type::Union
  94. 1 variant const: :auto
  95. 1 variant Integer
  96. # @!method self.variants
  97. # @return [Array(Symbol, :auto, Integer)]
  98. end
  99. # Number of evaluation samples to generate per training step.
  100. #
  101. # @see OpenAI::Models::FineTuning::ReinforcementHyperparameters#eval_samples
  102. 1 module EvalSamples
  103. 1 extend OpenAI::Internal::Type::Union
  104. 1 variant const: :auto
  105. 1 variant Integer
  106. # @!method self.variants
  107. # @return [Array(Symbol, :auto, Integer)]
  108. end
  109. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  110. # avoid overfitting.
  111. #
  112. # @see OpenAI::Models::FineTuning::ReinforcementHyperparameters#learning_rate_multiplier
  113. 1 module LearningRateMultiplier
  114. 1 extend OpenAI::Internal::Type::Union
  115. 1 variant const: :auto
  116. 1 variant Float
  117. # @!method self.variants
  118. # @return [Array(Symbol, :auto, Float)]
  119. end
  120. # The number of epochs to train the model for. An epoch refers to one full cycle
  121. # through the training dataset.
  122. #
  123. # @see OpenAI::Models::FineTuning::ReinforcementHyperparameters#n_epochs
  124. 1 module NEpochs
  125. 1 extend OpenAI::Internal::Type::Union
  126. 1 variant const: :auto
  127. 1 variant Integer
  128. # @!method self.variants
  129. # @return [Array(Symbol, :auto, Integer)]
  130. end
  131. # Level of reasoning effort.
  132. #
  133. # @see OpenAI::Models::FineTuning::ReinforcementHyperparameters#reasoning_effort
  134. 1 module ReasoningEffort
  135. 1 extend OpenAI::Internal::Type::Enum
  136. 1 DEFAULT = :default
  137. 1 LOW = :low
  138. 1 MEDIUM = :medium
  139. 1 HIGH = :high
  140. # @!method self.values
  141. # @return [Array<Symbol>]
  142. end
  143. end
  144. end
  145. end
  146. end

openai-ruby/lib/openai/models/fine_tuning/reinforcement_method.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 class ReinforcementMethod < OpenAI::Internal::Type::BaseModel
  6. # @!attribute grader
  7. # The grader used for the fine-tuning job.
  8. #
  9. # @return [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader]
  10. 1 required :grader, union: -> { OpenAI::FineTuning::ReinforcementMethod::Grader }
  11. # @!attribute hyperparameters
  12. # The hyperparameters used for the reinforcement fine-tuning job.
  13. #
  14. # @return [OpenAI::Models::FineTuning::ReinforcementHyperparameters, nil]
  15. 1 optional :hyperparameters, -> { OpenAI::FineTuning::ReinforcementHyperparameters }
  16. # @!method initialize(grader:, hyperparameters: nil)
  17. # Configuration for the reinforcement fine-tuning method.
  18. #
  19. # @param grader [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader] The grader used for the fine-tuning job.
  20. #
  21. # @param hyperparameters [OpenAI::Models::FineTuning::ReinforcementHyperparameters] The hyperparameters used for the reinforcement fine-tuning job.
  22. # The grader used for the fine-tuning job.
  23. #
  24. # @see OpenAI::Models::FineTuning::ReinforcementMethod#grader
  25. 1 module Grader
  26. 1 extend OpenAI::Internal::Type::Union
  27. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  28. 1 variant -> { OpenAI::Graders::StringCheckGrader }
  29. # A TextSimilarityGrader object which grades text based on similarity metrics.
  30. 1 variant -> { OpenAI::Graders::TextSimilarityGrader }
  31. # A PythonGrader object that runs a python script on the input.
  32. 1 variant -> { OpenAI::Graders::PythonGrader }
  33. # A ScoreModelGrader object that uses a model to assign a score to the input.
  34. 1 variant -> { OpenAI::Graders::ScoreModelGrader }
  35. # A MultiGrader object combines the output of multiple graders to produce a single score.
  36. 1 variant -> { OpenAI::Graders::MultiGrader }
  37. # @!method self.variants
  38. # @return [Array(OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader)]
  39. end
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/fine_tuning/supervised_hyperparameters.rb

95.0% lines covered

100.0% branches covered

20 relevant lines. 19 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 class SupervisedHyperparameters < OpenAI::Internal::Type::BaseModel
  6. # @!attribute batch_size
  7. # Number of examples in each batch. A larger batch size means that model
  8. # parameters are updated less frequently, but with lower variance.
  9. #
  10. # @return [Symbol, :auto, Integer, nil]
  11. 1 optional :batch_size, union: -> { OpenAI::FineTuning::SupervisedHyperparameters::BatchSize }
  12. # @!attribute learning_rate_multiplier
  13. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  14. # avoid overfitting.
  15. #
  16. # @return [Symbol, :auto, Float, nil]
  17. 1 optional :learning_rate_multiplier,
  18. union: -> { OpenAI::FineTuning::SupervisedHyperparameters::LearningRateMultiplier }
  19. # @!attribute n_epochs
  20. # The number of epochs to train the model for. An epoch refers to one full cycle
  21. # through the training dataset.
  22. #
  23. # @return [Symbol, :auto, Integer, nil]
  24. 1 optional :n_epochs, union: -> { OpenAI::FineTuning::SupervisedHyperparameters::NEpochs }
  25. # @!method initialize(batch_size: nil, learning_rate_multiplier: nil, n_epochs: nil)
  26. # Some parameter documentations has been truncated, see
  27. # {OpenAI::Models::FineTuning::SupervisedHyperparameters} for more details.
  28. #
  29. # The hyperparameters used for the fine-tuning job.
  30. #
  31. # @param batch_size [Symbol, :auto, Integer] Number of examples in each batch. A larger batch size means that model parameter
  32. #
  33. # @param learning_rate_multiplier [Symbol, :auto, Float] Scaling factor for the learning rate. A smaller learning rate may be useful to a
  34. #
  35. # @param n_epochs [Symbol, :auto, Integer] The number of epochs to train the model for. An epoch refers to one full cycle t
  36. # Number of examples in each batch. A larger batch size means that model
  37. # parameters are updated less frequently, but with lower variance.
  38. #
  39. # @see OpenAI::Models::FineTuning::SupervisedHyperparameters#batch_size
  40. 1 module BatchSize
  41. 1 extend OpenAI::Internal::Type::Union
  42. 1 variant const: :auto
  43. 1 variant Integer
  44. # @!method self.variants
  45. # @return [Array(Symbol, :auto, Integer)]
  46. end
  47. # Scaling factor for the learning rate. A smaller learning rate may be useful to
  48. # avoid overfitting.
  49. #
  50. # @see OpenAI::Models::FineTuning::SupervisedHyperparameters#learning_rate_multiplier
  51. 1 module LearningRateMultiplier
  52. 1 extend OpenAI::Internal::Type::Union
  53. 1 variant const: :auto
  54. 1 variant Float
  55. # @!method self.variants
  56. # @return [Array(Symbol, :auto, Float)]
  57. end
  58. # The number of epochs to train the model for. An epoch refers to one full cycle
  59. # through the training dataset.
  60. #
  61. # @see OpenAI::Models::FineTuning::SupervisedHyperparameters#n_epochs
  62. 1 module NEpochs
  63. 1 extend OpenAI::Internal::Type::Union
  64. 1 variant const: :auto
  65. 1 variant Integer
  66. # @!method self.variants
  67. # @return [Array(Symbol, :auto, Integer)]
  68. end
  69. end
  70. end
  71. end
  72. end

openai-ruby/lib/openai/models/fine_tuning/supervised_method.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module FineTuning
  5. 1 class SupervisedMethod < OpenAI::Internal::Type::BaseModel
  6. # @!attribute hyperparameters
  7. # The hyperparameters used for the fine-tuning job.
  8. #
  9. # @return [OpenAI::Models::FineTuning::SupervisedHyperparameters, nil]
  10. 1 optional :hyperparameters, -> { OpenAI::FineTuning::SupervisedHyperparameters }
  11. # @!method initialize(hyperparameters: nil)
  12. # Configuration for the supervised fine-tuning method.
  13. #
  14. # @param hyperparameters [OpenAI::Models::FineTuning::SupervisedHyperparameters] The hyperparameters used for the fine-tuning job.
  15. end
  16. end
  17. end
  18. end

openai-ruby/lib/openai/models/function_definition.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class FunctionDefinition < OpenAI::Internal::Type::BaseModel
  5. # @!attribute name
  6. # The name of the function to be called. Must be a-z, A-Z, 0-9, or contain
  7. # underscores and dashes, with a maximum length of 64.
  8. #
  9. # @return [String]
  10. 1 required :name, String
  11. # @!attribute description
  12. # A description of what the function does, used by the model to choose when and
  13. # how to call the function.
  14. #
  15. # @return [String, nil]
  16. 1 optional :description, String
  17. # @!attribute parameters
  18. # The parameters the functions accepts, described as a JSON Schema object. See the
  19. # [guide](https://platform.openai.com/docs/guides/function-calling) for examples,
  20. # and the
  21. # [JSON Schema reference](https://json-schema.org/understanding-json-schema/) for
  22. # documentation about the format.
  23. #
  24. # Omitting `parameters` defines a function with an empty parameter list.
  25. #
  26. # @return [Hash{Symbol=>Object}, nil]
  27. 1 optional :parameters, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  28. # @!attribute strict
  29. # Whether to enable strict schema adherence when generating the function call. If
  30. # set to true, the model will follow the exact schema defined in the `parameters`
  31. # field. Only a subset of JSON Schema is supported when `strict` is `true`. Learn
  32. # more about Structured Outputs in the
  33. # [function calling guide](https://platform.openai.com/docs/guides/function-calling).
  34. #
  35. # @return [Boolean, nil]
  36. 1 optional :strict, OpenAI::Internal::Type::Boolean, nil?: true
  37. # @!method initialize(name:, description: nil, parameters: nil, strict: nil)
  38. # Some parameter documentations has been truncated, see
  39. # {OpenAI::Models::FunctionDefinition} for more details.
  40. #
  41. # @param name [String] The name of the function to be called. Must be a-z, A-Z, 0-9, or contain undersc
  42. #
  43. # @param description [String] A description of what the function does, used by the model to choose when and ho
  44. #
  45. # @param parameters [Hash{Symbol=>Object}] The parameters the functions accepts, described as a JSON Schema object. See the
  46. #
  47. # @param strict [Boolean, nil] Whether to enable strict schema adherence when generating the function call. If
  48. end
  49. end
  50. end

openai-ruby/lib/openai/models/function_parameters.rb

100.0% lines covered

100.0% branches covered

3 relevant lines. 3 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @type [OpenAI::Internal::Type::Converter]
  5. 1 FunctionParameters = OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  6. end
  7. end

openai-ruby/lib/openai/models/graders/label_model_grader.rb

100.0% lines covered

100.0% branches covered

39 relevant lines. 39 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Graders
  5. 1 class LabelModelGrader < OpenAI::Internal::Type::BaseModel
  6. # @!attribute input
  7. #
  8. # @return [Array<OpenAI::Models::Graders::LabelModelGrader::Input>]
  9. 1 required :input, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Graders::LabelModelGrader::Input] }
  10. # @!attribute labels
  11. # The labels to assign to each item in the evaluation.
  12. #
  13. # @return [Array<String>]
  14. 1 required :labels, OpenAI::Internal::Type::ArrayOf[String]
  15. # @!attribute model
  16. # The model to use for the evaluation. Must support structured outputs.
  17. #
  18. # @return [String]
  19. 1 required :model, String
  20. # @!attribute name
  21. # The name of the grader.
  22. #
  23. # @return [String]
  24. 1 required :name, String
  25. # @!attribute passing_labels
  26. # The labels that indicate a passing result. Must be a subset of labels.
  27. #
  28. # @return [Array<String>]
  29. 1 required :passing_labels, OpenAI::Internal::Type::ArrayOf[String]
  30. # @!attribute type
  31. # The object type, which is always `label_model`.
  32. #
  33. # @return [Symbol, :label_model]
  34. 1 required :type, const: :label_model
  35. # @!method initialize(input:, labels:, model:, name:, passing_labels:, type: :label_model)
  36. # A LabelModelGrader object which uses a model to assign labels to each item in
  37. # the evaluation.
  38. #
  39. # @param input [Array<OpenAI::Models::Graders::LabelModelGrader::Input>]
  40. #
  41. # @param labels [Array<String>] The labels to assign to each item in the evaluation.
  42. #
  43. # @param model [String] The model to use for the evaluation. Must support structured outputs.
  44. #
  45. # @param name [String] The name of the grader.
  46. #
  47. # @param passing_labels [Array<String>] The labels that indicate a passing result. Must be a subset of labels.
  48. #
  49. # @param type [Symbol, :label_model] The object type, which is always `label_model`.
  50. 1 class Input < OpenAI::Internal::Type::BaseModel
  51. # @!attribute content
  52. # Inputs to the model - can contain template strings.
  53. #
  54. # @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Graders::LabelModelGrader::Input::Content::OutputText, OpenAI::Models::Graders::LabelModelGrader::Input::Content::InputImage, Array<Object>]
  55. 1 required :content, union: -> { OpenAI::Graders::LabelModelGrader::Input::Content }
  56. # @!attribute role
  57. # The role of the message input. One of `user`, `assistant`, `system`, or
  58. # `developer`.
  59. #
  60. # @return [Symbol, OpenAI::Models::Graders::LabelModelGrader::Input::Role]
  61. 1 required :role, enum: -> { OpenAI::Graders::LabelModelGrader::Input::Role }
  62. # @!attribute type
  63. # The type of the message input. Always `message`.
  64. #
  65. # @return [Symbol, OpenAI::Models::Graders::LabelModelGrader::Input::Type, nil]
  66. 1 optional :type, enum: -> { OpenAI::Graders::LabelModelGrader::Input::Type }
  67. # @!method initialize(content:, role:, type: nil)
  68. # Some parameter documentations has been truncated, see
  69. # {OpenAI::Models::Graders::LabelModelGrader::Input} for more details.
  70. #
  71. # A message input to the model with a role indicating instruction following
  72. # hierarchy. Instructions given with the `developer` or `system` role take
  73. # precedence over instructions given with the `user` role. Messages with the
  74. # `assistant` role are presumed to have been generated by the model in previous
  75. # interactions.
  76. #
  77. # @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Graders::LabelModelGrader::Input::Content::OutputText, OpenAI::Models::Graders::LabelModelGrader::Input::Content::InputImage, Array<Object>] Inputs to the model - can contain template strings.
  78. #
  79. # @param role [Symbol, OpenAI::Models::Graders::LabelModelGrader::Input::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  80. #
  81. # @param type [Symbol, OpenAI::Models::Graders::LabelModelGrader::Input::Type] The type of the message input. Always `message`.
  82. # Inputs to the model - can contain template strings.
  83. #
  84. # @see OpenAI::Models::Graders::LabelModelGrader::Input#content
  85. 1 module Content
  86. 1 extend OpenAI::Internal::Type::Union
  87. # A text input to the model.
  88. 1 variant String
  89. # A text input to the model.
  90. 1 variant -> { OpenAI::Responses::ResponseInputText }
  91. # A text output from the model.
  92. 1 variant -> { OpenAI::Graders::LabelModelGrader::Input::Content::OutputText }
  93. # An image input to the model.
  94. 1 variant -> { OpenAI::Graders::LabelModelGrader::Input::Content::InputImage }
  95. # A list of inputs, each of which may be either an input text or input image object.
  96. 1 variant -> { OpenAI::Models::Graders::LabelModelGrader::Input::Content::AnArrayOfInputTextAndInputImageArray }
  97. 1 class OutputText < OpenAI::Internal::Type::BaseModel
  98. # @!attribute text
  99. # The text output from the model.
  100. #
  101. # @return [String]
  102. 1 required :text, String
  103. # @!attribute type
  104. # The type of the output text. Always `output_text`.
  105. #
  106. # @return [Symbol, :output_text]
  107. 1 required :type, const: :output_text
  108. # @!method initialize(text:, type: :output_text)
  109. # Some parameter documentations has been truncated, see
  110. # {OpenAI::Models::Graders::LabelModelGrader::Input::Content::OutputText} for more
  111. # details.
  112. #
  113. # A text output from the model.
  114. #
  115. # @param text [String] The text output from the model.
  116. #
  117. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  118. end
  119. 1 class InputImage < OpenAI::Internal::Type::BaseModel
  120. # @!attribute image_url
  121. # The URL of the image input.
  122. #
  123. # @return [String]
  124. 1 required :image_url, String
  125. # @!attribute type
  126. # The type of the image input. Always `input_image`.
  127. #
  128. # @return [Symbol, :input_image]
  129. 1 required :type, const: :input_image
  130. # @!attribute detail
  131. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  132. # `auto`. Defaults to `auto`.
  133. #
  134. # @return [String, nil]
  135. 1 optional :detail, String
  136. # @!method initialize(image_url:, detail: nil, type: :input_image)
  137. # Some parameter documentations has been truncated, see
  138. # {OpenAI::Models::Graders::LabelModelGrader::Input::Content::InputImage} for more
  139. # details.
  140. #
  141. # An image input to the model.
  142. #
  143. # @param image_url [String] The URL of the image input.
  144. #
  145. # @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
  146. #
  147. # @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
  148. end
  149. # @!method self.variants
  150. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Graders::LabelModelGrader::Input::Content::OutputText, OpenAI::Models::Graders::LabelModelGrader::Input::Content::InputImage, Array<Object>)]
  151. # @type [OpenAI::Internal::Type::Converter]
  152. 1 AnArrayOfInputTextAndInputImageArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
  153. end
  154. # The role of the message input. One of `user`, `assistant`, `system`, or
  155. # `developer`.
  156. #
  157. # @see OpenAI::Models::Graders::LabelModelGrader::Input#role
  158. 1 module Role
  159. 1 extend OpenAI::Internal::Type::Enum
  160. 1 USER = :user
  161. 1 ASSISTANT = :assistant
  162. 1 SYSTEM = :system
  163. 1 DEVELOPER = :developer
  164. # @!method self.values
  165. # @return [Array<Symbol>]
  166. end
  167. # The type of the message input. Always `message`.
  168. #
  169. # @see OpenAI::Models::Graders::LabelModelGrader::Input#type
  170. 1 module Type
  171. 1 extend OpenAI::Internal::Type::Enum
  172. 1 MESSAGE = :message
  173. # @!method self.values
  174. # @return [Array<Symbol>]
  175. end
  176. end
  177. end
  178. end
  179. 1 LabelModelGrader = Graders::LabelModelGrader
  180. end
  181. end

openai-ruby/lib/openai/models/graders/multi_grader.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Graders
  5. 1 class MultiGrader < OpenAI::Internal::Type::BaseModel
  6. # @!attribute calculate_output
  7. # A formula to calculate the output based on grader results.
  8. #
  9. # @return [String]
  10. 1 required :calculate_output, String
  11. # @!attribute graders
  12. # A StringCheckGrader object that performs a string comparison between input and
  13. # reference using a specified operation.
  14. #
  15. # @return [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::LabelModelGrader]
  16. 1 required :graders, union: -> { OpenAI::Graders::MultiGrader::Graders }
  17. # @!attribute name
  18. # The name of the grader.
  19. #
  20. # @return [String]
  21. 1 required :name, String
  22. # @!attribute type
  23. # The object type, which is always `multi`.
  24. #
  25. # @return [Symbol, :multi]
  26. 1 required :type, const: :multi
  27. # @!method initialize(calculate_output:, graders:, name:, type: :multi)
  28. # Some parameter documentations has been truncated, see
  29. # {OpenAI::Models::Graders::MultiGrader} for more details.
  30. #
  31. # A MultiGrader object combines the output of multiple graders to produce a single
  32. # score.
  33. #
  34. # @param calculate_output [String] A formula to calculate the output based on grader results.
  35. #
  36. # @param graders [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::LabelModelGrader] A StringCheckGrader object that performs a string comparison between input and r
  37. #
  38. # @param name [String] The name of the grader.
  39. #
  40. # @param type [Symbol, :multi] The object type, which is always `multi`.
  41. # A StringCheckGrader object that performs a string comparison between input and
  42. # reference using a specified operation.
  43. #
  44. # @see OpenAI::Models::Graders::MultiGrader#graders
  45. 1 module Graders
  46. 1 extend OpenAI::Internal::Type::Union
  47. # A StringCheckGrader object that performs a string comparison between input and reference using a specified operation.
  48. 1 variant -> { OpenAI::Graders::StringCheckGrader }
  49. # A TextSimilarityGrader object which grades text based on similarity metrics.
  50. 1 variant -> { OpenAI::Graders::TextSimilarityGrader }
  51. # A PythonGrader object that runs a python script on the input.
  52. 1 variant -> { OpenAI::Graders::PythonGrader }
  53. # A ScoreModelGrader object that uses a model to assign a score to the input.
  54. 1 variant -> { OpenAI::Graders::ScoreModelGrader }
  55. # A LabelModelGrader object which uses a model to assign labels to each item
  56. # in the evaluation.
  57. 1 variant -> { OpenAI::Graders::LabelModelGrader }
  58. # @!method self.variants
  59. # @return [Array(OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::LabelModelGrader)]
  60. end
  61. end
  62. end
  63. 1 MultiGrader = Graders::MultiGrader
  64. end
  65. end

openai-ruby/lib/openai/models/graders/python_grader.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Graders
  5. 1 class PythonGrader < OpenAI::Internal::Type::BaseModel
  6. # @!attribute name
  7. # The name of the grader.
  8. #
  9. # @return [String]
  10. 1 required :name, String
  11. # @!attribute source
  12. # The source code of the python script.
  13. #
  14. # @return [String]
  15. 1 required :source, String
  16. # @!attribute type
  17. # The object type, which is always `python`.
  18. #
  19. # @return [Symbol, :python]
  20. 1 required :type, const: :python
  21. # @!attribute image_tag
  22. # The image tag to use for the python script.
  23. #
  24. # @return [String, nil]
  25. 1 optional :image_tag, String
  26. # @!method initialize(name:, source:, image_tag: nil, type: :python)
  27. # A PythonGrader object that runs a python script on the input.
  28. #
  29. # @param name [String] The name of the grader.
  30. #
  31. # @param source [String] The source code of the python script.
  32. #
  33. # @param image_tag [String] The image tag to use for the python script.
  34. #
  35. # @param type [Symbol, :python] The object type, which is always `python`.
  36. end
  37. end
  38. 1 PythonGrader = Graders::PythonGrader
  39. end
  40. end

openai-ruby/lib/openai/models/graders/score_model_grader.rb

100.0% lines covered

100.0% branches covered

39 relevant lines. 39 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Graders
  5. 1 class ScoreModelGrader < OpenAI::Internal::Type::BaseModel
  6. # @!attribute input
  7. # The input text. This may include template strings.
  8. #
  9. # @return [Array<OpenAI::Models::Graders::ScoreModelGrader::Input>]
  10. 1 required :input, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Graders::ScoreModelGrader::Input] }
  11. # @!attribute model
  12. # The model to use for the evaluation.
  13. #
  14. # @return [String]
  15. 1 required :model, String
  16. # @!attribute name
  17. # The name of the grader.
  18. #
  19. # @return [String]
  20. 1 required :name, String
  21. # @!attribute type
  22. # The object type, which is always `score_model`.
  23. #
  24. # @return [Symbol, :score_model]
  25. 1 required :type, const: :score_model
  26. # @!attribute range
  27. # The range of the score. Defaults to `[0, 1]`.
  28. #
  29. # @return [Array<Float>, nil]
  30. 1 optional :range, OpenAI::Internal::Type::ArrayOf[Float]
  31. # @!attribute sampling_params
  32. # The sampling parameters for the model.
  33. #
  34. # @return [Object, nil]
  35. 1 optional :sampling_params, OpenAI::Internal::Type::Unknown
  36. # @!method initialize(input:, model:, name:, range: nil, sampling_params: nil, type: :score_model)
  37. # A ScoreModelGrader object that uses a model to assign a score to the input.
  38. #
  39. # @param input [Array<OpenAI::Models::Graders::ScoreModelGrader::Input>] The input text. This may include template strings.
  40. #
  41. # @param model [String] The model to use for the evaluation.
  42. #
  43. # @param name [String] The name of the grader.
  44. #
  45. # @param range [Array<Float>] The range of the score. Defaults to `[0, 1]`.
  46. #
  47. # @param sampling_params [Object] The sampling parameters for the model.
  48. #
  49. # @param type [Symbol, :score_model] The object type, which is always `score_model`.
  50. 1 class Input < OpenAI::Internal::Type::BaseModel
  51. # @!attribute content
  52. # Inputs to the model - can contain template strings.
  53. #
  54. # @return [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::OutputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::InputImage, Array<Object>]
  55. 1 required :content, union: -> { OpenAI::Graders::ScoreModelGrader::Input::Content }
  56. # @!attribute role
  57. # The role of the message input. One of `user`, `assistant`, `system`, or
  58. # `developer`.
  59. #
  60. # @return [Symbol, OpenAI::Models::Graders::ScoreModelGrader::Input::Role]
  61. 1 required :role, enum: -> { OpenAI::Graders::ScoreModelGrader::Input::Role }
  62. # @!attribute type
  63. # The type of the message input. Always `message`.
  64. #
  65. # @return [Symbol, OpenAI::Models::Graders::ScoreModelGrader::Input::Type, nil]
  66. 1 optional :type, enum: -> { OpenAI::Graders::ScoreModelGrader::Input::Type }
  67. # @!method initialize(content:, role:, type: nil)
  68. # Some parameter documentations has been truncated, see
  69. # {OpenAI::Models::Graders::ScoreModelGrader::Input} for more details.
  70. #
  71. # A message input to the model with a role indicating instruction following
  72. # hierarchy. Instructions given with the `developer` or `system` role take
  73. # precedence over instructions given with the `user` role. Messages with the
  74. # `assistant` role are presumed to have been generated by the model in previous
  75. # interactions.
  76. #
  77. # @param content [String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::OutputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::InputImage, Array<Object>] Inputs to the model - can contain template strings.
  78. #
  79. # @param role [Symbol, OpenAI::Models::Graders::ScoreModelGrader::Input::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  80. #
  81. # @param type [Symbol, OpenAI::Models::Graders::ScoreModelGrader::Input::Type] The type of the message input. Always `message`.
  82. # Inputs to the model - can contain template strings.
  83. #
  84. # @see OpenAI::Models::Graders::ScoreModelGrader::Input#content
  85. 1 module Content
  86. 1 extend OpenAI::Internal::Type::Union
  87. # A text input to the model.
  88. 1 variant String
  89. # A text input to the model.
  90. 1 variant -> { OpenAI::Responses::ResponseInputText }
  91. # A text output from the model.
  92. 1 variant -> { OpenAI::Graders::ScoreModelGrader::Input::Content::OutputText }
  93. # An image input to the model.
  94. 1 variant -> { OpenAI::Graders::ScoreModelGrader::Input::Content::InputImage }
  95. # A list of inputs, each of which may be either an input text or input image object.
  96. 1 variant -> { OpenAI::Models::Graders::ScoreModelGrader::Input::Content::AnArrayOfInputTextAndInputImageArray }
  97. 1 class OutputText < OpenAI::Internal::Type::BaseModel
  98. # @!attribute text
  99. # The text output from the model.
  100. #
  101. # @return [String]
  102. 1 required :text, String
  103. # @!attribute type
  104. # The type of the output text. Always `output_text`.
  105. #
  106. # @return [Symbol, :output_text]
  107. 1 required :type, const: :output_text
  108. # @!method initialize(text:, type: :output_text)
  109. # Some parameter documentations has been truncated, see
  110. # {OpenAI::Models::Graders::ScoreModelGrader::Input::Content::OutputText} for more
  111. # details.
  112. #
  113. # A text output from the model.
  114. #
  115. # @param text [String] The text output from the model.
  116. #
  117. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  118. end
  119. 1 class InputImage < OpenAI::Internal::Type::BaseModel
  120. # @!attribute image_url
  121. # The URL of the image input.
  122. #
  123. # @return [String]
  124. 1 required :image_url, String
  125. # @!attribute type
  126. # The type of the image input. Always `input_image`.
  127. #
  128. # @return [Symbol, :input_image]
  129. 1 required :type, const: :input_image
  130. # @!attribute detail
  131. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  132. # `auto`. Defaults to `auto`.
  133. #
  134. # @return [String, nil]
  135. 1 optional :detail, String
  136. # @!method initialize(image_url:, detail: nil, type: :input_image)
  137. # Some parameter documentations has been truncated, see
  138. # {OpenAI::Models::Graders::ScoreModelGrader::Input::Content::InputImage} for more
  139. # details.
  140. #
  141. # An image input to the model.
  142. #
  143. # @param image_url [String] The URL of the image input.
  144. #
  145. # @param detail [String] The detail level of the image to be sent to the model. One of `high`, `low`, or
  146. #
  147. # @param type [Symbol, :input_image] The type of the image input. Always `input_image`.
  148. end
  149. # @!method self.variants
  150. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::OutputText, OpenAI::Models::Graders::ScoreModelGrader::Input::Content::InputImage, Array<Object>)]
  151. # @type [OpenAI::Internal::Type::Converter]
  152. 1 AnArrayOfInputTextAndInputImageArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::Unknown]
  153. end
  154. # The role of the message input. One of `user`, `assistant`, `system`, or
  155. # `developer`.
  156. #
  157. # @see OpenAI::Models::Graders::ScoreModelGrader::Input#role
  158. 1 module Role
  159. 1 extend OpenAI::Internal::Type::Enum
  160. 1 USER = :user
  161. 1 ASSISTANT = :assistant
  162. 1 SYSTEM = :system
  163. 1 DEVELOPER = :developer
  164. # @!method self.values
  165. # @return [Array<Symbol>]
  166. end
  167. # The type of the message input. Always `message`.
  168. #
  169. # @see OpenAI::Models::Graders::ScoreModelGrader::Input#type
  170. 1 module Type
  171. 1 extend OpenAI::Internal::Type::Enum
  172. 1 MESSAGE = :message
  173. # @!method self.values
  174. # @return [Array<Symbol>]
  175. end
  176. end
  177. end
  178. end
  179. 1 ScoreModelGrader = Graders::ScoreModelGrader
  180. end
  181. end

openai-ruby/lib/openai/models/graders/string_check_grader.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Graders
  5. 1 class StringCheckGrader < OpenAI::Internal::Type::BaseModel
  6. # @!attribute input
  7. # The input text. This may include template strings.
  8. #
  9. # @return [String]
  10. 1 required :input, String
  11. # @!attribute name
  12. # The name of the grader.
  13. #
  14. # @return [String]
  15. 1 required :name, String
  16. # @!attribute operation
  17. # The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.
  18. #
  19. # @return [Symbol, OpenAI::Models::Graders::StringCheckGrader::Operation]
  20. 1 required :operation, enum: -> { OpenAI::Graders::StringCheckGrader::Operation }
  21. # @!attribute reference
  22. # The reference text. This may include template strings.
  23. #
  24. # @return [String]
  25. 1 required :reference, String
  26. # @!attribute type
  27. # The object type, which is always `string_check`.
  28. #
  29. # @return [Symbol, :string_check]
  30. 1 required :type, const: :string_check
  31. # @!method initialize(input:, name:, operation:, reference:, type: :string_check)
  32. # A StringCheckGrader object that performs a string comparison between input and
  33. # reference using a specified operation.
  34. #
  35. # @param input [String] The input text. This may include template strings.
  36. #
  37. # @param name [String] The name of the grader.
  38. #
  39. # @param operation [Symbol, OpenAI::Models::Graders::StringCheckGrader::Operation] The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.
  40. #
  41. # @param reference [String] The reference text. This may include template strings.
  42. #
  43. # @param type [Symbol, :string_check] The object type, which is always `string_check`.
  44. # The string check operation to perform. One of `eq`, `ne`, `like`, or `ilike`.
  45. #
  46. # @see OpenAI::Models::Graders::StringCheckGrader#operation
  47. 1 module Operation
  48. 1 extend OpenAI::Internal::Type::Enum
  49. 1 EQ = :eq
  50. 1 NE = :ne
  51. 1 LIKE = :like
  52. 1 ILIKE = :ilike
  53. # @!method self.values
  54. # @return [Array<Symbol>]
  55. end
  56. end
  57. end
  58. 1 StringCheckGrader = Graders::StringCheckGrader
  59. end
  60. end

openai-ruby/lib/openai/models/graders/text_similarity_grader.rb

100.0% lines covered

100.0% branches covered

22 relevant lines. 22 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Graders
  5. 1 class TextSimilarityGrader < OpenAI::Internal::Type::BaseModel
  6. # @!attribute evaluation_metric
  7. # The evaluation metric to use. One of `fuzzy_match`, `bleu`, `gleu`, `meteor`,
  8. # `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, or `rouge_l`.
  9. #
  10. # @return [Symbol, OpenAI::Models::Graders::TextSimilarityGrader::EvaluationMetric]
  11. 1 required :evaluation_metric, enum: -> { OpenAI::Graders::TextSimilarityGrader::EvaluationMetric }
  12. # @!attribute input
  13. # The text being graded.
  14. #
  15. # @return [String]
  16. 1 required :input, String
  17. # @!attribute name
  18. # The name of the grader.
  19. #
  20. # @return [String]
  21. 1 required :name, String
  22. # @!attribute reference
  23. # The text being graded against.
  24. #
  25. # @return [String]
  26. 1 required :reference, String
  27. # @!attribute type
  28. # The type of grader.
  29. #
  30. # @return [Symbol, :text_similarity]
  31. 1 required :type, const: :text_similarity
  32. # @!method initialize(evaluation_metric:, input:, name:, reference:, type: :text_similarity)
  33. # Some parameter documentations has been truncated, see
  34. # {OpenAI::Models::Graders::TextSimilarityGrader} for more details.
  35. #
  36. # A TextSimilarityGrader object which grades text based on similarity metrics.
  37. #
  38. # @param evaluation_metric [Symbol, OpenAI::Models::Graders::TextSimilarityGrader::EvaluationMetric] The evaluation metric to use. One of `fuzzy_match`, `bleu`, `gleu`, `meteor`, `r
  39. #
  40. # @param input [String] The text being graded.
  41. #
  42. # @param name [String] The name of the grader.
  43. #
  44. # @param reference [String] The text being graded against.
  45. #
  46. # @param type [Symbol, :text_similarity] The type of grader.
  47. # The evaluation metric to use. One of `fuzzy_match`, `bleu`, `gleu`, `meteor`,
  48. # `rouge_1`, `rouge_2`, `rouge_3`, `rouge_4`, `rouge_5`, or `rouge_l`.
  49. #
  50. # @see OpenAI::Models::Graders::TextSimilarityGrader#evaluation_metric
  51. 1 module EvaluationMetric
  52. 1 extend OpenAI::Internal::Type::Enum
  53. 1 FUZZY_MATCH = :fuzzy_match
  54. 1 BLEU = :bleu
  55. 1 GLEU = :gleu
  56. 1 METEOR = :meteor
  57. 1 ROUGE_1 = :rouge_1
  58. 1 ROUGE_2 = :rouge_2
  59. 1 ROUGE_3 = :rouge_3
  60. 1 ROUGE_4 = :rouge_4
  61. 1 ROUGE_5 = :rouge_5
  62. 1 ROUGE_L = :rouge_l
  63. # @!method self.values
  64. # @return [Array<Symbol>]
  65. end
  66. end
  67. end
  68. 1 TextSimilarityGrader = Graders::TextSimilarityGrader
  69. end
  70. end

openai-ruby/lib/openai/models/image.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class Image < OpenAI::Internal::Type::BaseModel
  5. # @!attribute b64_json
  6. # The base64-encoded JSON of the generated image. Default value for `gpt-image-1`,
  7. # and only present if `response_format` is set to `b64_json` for `dall-e-2` and
  8. # `dall-e-3`.
  9. #
  10. # @return [String, nil]
  11. 1 optional :b64_json, String
  12. # @!attribute revised_prompt
  13. # For `dall-e-3` only, the revised prompt that was used to generate the image.
  14. #
  15. # @return [String, nil]
  16. 1 optional :revised_prompt, String
  17. # @!attribute url
  18. # When using `dall-e-2` or `dall-e-3`, the URL of the generated image if
  19. # `response_format` is set to `url` (default value). Unsupported for
  20. # `gpt-image-1`.
  21. #
  22. # @return [String, nil]
  23. 1 optional :url, String
  24. # @!method initialize(b64_json: nil, revised_prompt: nil, url: nil)
  25. # Some parameter documentations has been truncated, see {OpenAI::Models::Image}
  26. # for more details.
  27. #
  28. # Represents the content or the URL of an image generated by the OpenAI API.
  29. #
  30. # @param b64_json [String] The base64-encoded JSON of the generated image. Default value for `gpt-image-1`,
  31. #
  32. # @param revised_prompt [String] For `dall-e-3` only, the revised prompt that was used to generate the image.
  33. #
  34. # @param url [String] When using `dall-e-2` or `dall-e-3`, the URL of the generated image if `response
  35. end
  36. end
  37. end

openai-ruby/lib/openai/models/image_create_variation_params.rb

100.0% lines covered

100.0% branches covered

24 relevant lines. 24 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Images#create_variation
  5. 1 class ImageCreateVariationParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute image
  9. # The image to use as the basis for the variation(s). Must be a valid PNG file,
  10. # less than 4MB, and square.
  11. #
  12. # @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
  13. 1 required :image, OpenAI::Internal::Type::FileInput
  14. # @!attribute model
  15. # The model to use for image generation. Only `dall-e-2` is supported at this
  16. # time.
  17. #
  18. # @return [String, Symbol, OpenAI::Models::ImageModel, nil]
  19. 1 optional :model, union: -> { OpenAI::ImageCreateVariationParams::Model }, nil?: true
  20. # @!attribute n
  21. # The number of images to generate. Must be between 1 and 10.
  22. #
  23. # @return [Integer, nil]
  24. 1 optional :n, Integer, nil?: true
  25. # @!attribute response_format
  26. # The format in which the generated images are returned. Must be one of `url` or
  27. # `b64_json`. URLs are only valid for 60 minutes after the image has been
  28. # generated.
  29. #
  30. # @return [Symbol, OpenAI::Models::ImageCreateVariationParams::ResponseFormat, nil]
  31. 1 optional :response_format, enum: -> { OpenAI::ImageCreateVariationParams::ResponseFormat }, nil?: true
  32. # @!attribute size
  33. # The size of the generated images. Must be one of `256x256`, `512x512`, or
  34. # `1024x1024`.
  35. #
  36. # @return [Symbol, OpenAI::Models::ImageCreateVariationParams::Size, nil]
  37. 1 optional :size, enum: -> { OpenAI::ImageCreateVariationParams::Size }, nil?: true
  38. # @!attribute user
  39. # A unique identifier representing your end-user, which can help OpenAI to monitor
  40. # and detect abuse.
  41. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
  42. #
  43. # @return [String, nil]
  44. 1 optional :user, String
  45. # @!method initialize(image:, model: nil, n: nil, response_format: nil, size: nil, user: nil, request_options: {})
  46. # Some parameter documentations has been truncated, see
  47. # {OpenAI::Models::ImageCreateVariationParams} for more details.
  48. #
  49. # @param image [Pathname, StringIO, IO, String, OpenAI::FilePart] The image to use as the basis for the variation(s). Must be a valid PNG file, le
  50. #
  51. # @param model [String, Symbol, OpenAI::Models::ImageModel, nil] The model to use for image generation. Only `dall-e-2` is supported at this time
  52. #
  53. # @param n [Integer, nil] The number of images to generate. Must be between 1 and 10.
  54. #
  55. # @param response_format [Symbol, OpenAI::Models::ImageCreateVariationParams::ResponseFormat, nil] The format in which the generated images are returned. Must be one of `url` or `
  56. #
  57. # @param size [Symbol, OpenAI::Models::ImageCreateVariationParams::Size, nil] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x
  58. #
  59. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  60. #
  61. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  62. # The model to use for image generation. Only `dall-e-2` is supported at this
  63. # time.
  64. 1 module Model
  65. 1 extend OpenAI::Internal::Type::Union
  66. 1 variant String
  67. # The model to use for image generation. Only `dall-e-2` is supported at this time.
  68. 1 variant enum: -> { OpenAI::ImageModel }
  69. # @!method self.variants
  70. # @return [Array(String, Symbol, OpenAI::Models::ImageModel)]
  71. end
  72. # The format in which the generated images are returned. Must be one of `url` or
  73. # `b64_json`. URLs are only valid for 60 minutes after the image has been
  74. # generated.
  75. 1 module ResponseFormat
  76. 1 extend OpenAI::Internal::Type::Enum
  77. 1 URL = :url
  78. 1 B64_JSON = :b64_json
  79. # @!method self.values
  80. # @return [Array<Symbol>]
  81. end
  82. # The size of the generated images. Must be one of `256x256`, `512x512`, or
  83. # `1024x1024`.
  84. 1 module Size
  85. 1 extend OpenAI::Internal::Type::Enum
  86. 1 SIZE_256X256 = :"256x256"
  87. 1 SIZE_512X512 = :"512x512"
  88. 1 SIZE_1024X1024 = :"1024x1024"
  89. # @!method self.values
  90. # @return [Array<Symbol>]
  91. end
  92. end
  93. end
  94. end

openai-ruby/lib/openai/models/image_edit_completed_event.rb

100.0% lines covered

100.0% branches covered

41 relevant lines. 41 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ImageEditCompletedEvent < OpenAI::Internal::Type::BaseModel
  5. # @!attribute b64_json
  6. # Base64-encoded final edited image data, suitable for rendering as an image.
  7. #
  8. # @return [String]
  9. 1 required :b64_json, String
  10. # @!attribute background
  11. # The background setting for the edited image.
  12. #
  13. # @return [Symbol, OpenAI::Models::ImageEditCompletedEvent::Background]
  14. 1 required :background, enum: -> { OpenAI::ImageEditCompletedEvent::Background }
  15. # @!attribute created_at
  16. # The Unix timestamp when the event was created.
  17. #
  18. # @return [Integer]
  19. 1 required :created_at, Integer
  20. # @!attribute output_format
  21. # The output format for the edited image.
  22. #
  23. # @return [Symbol, OpenAI::Models::ImageEditCompletedEvent::OutputFormat]
  24. 1 required :output_format, enum: -> { OpenAI::ImageEditCompletedEvent::OutputFormat }
  25. # @!attribute quality
  26. # The quality setting for the edited image.
  27. #
  28. # @return [Symbol, OpenAI::Models::ImageEditCompletedEvent::Quality]
  29. 1 required :quality, enum: -> { OpenAI::ImageEditCompletedEvent::Quality }
  30. # @!attribute size
  31. # The size of the edited image.
  32. #
  33. # @return [Symbol, OpenAI::Models::ImageEditCompletedEvent::Size]
  34. 1 required :size, enum: -> { OpenAI::ImageEditCompletedEvent::Size }
  35. # @!attribute type
  36. # The type of the event. Always `image_edit.completed`.
  37. #
  38. # @return [Symbol, :"image_edit.completed"]
  39. 1 required :type, const: :"image_edit.completed"
  40. # @!attribute usage
  41. # For `gpt-image-1` only, the token usage information for the image generation.
  42. #
  43. # @return [OpenAI::Models::ImageEditCompletedEvent::Usage]
  44. 1 required :usage, -> { OpenAI::ImageEditCompletedEvent::Usage }
  45. # @!method initialize(b64_json:, background:, created_at:, output_format:, quality:, size:, usage:, type: :"image_edit.completed")
  46. # Some parameter documentations has been truncated, see
  47. # {OpenAI::Models::ImageEditCompletedEvent} for more details.
  48. #
  49. # Emitted when image editing has completed and the final image is available.
  50. #
  51. # @param b64_json [String] Base64-encoded final edited image data, suitable for rendering as an image.
  52. #
  53. # @param background [Symbol, OpenAI::Models::ImageEditCompletedEvent::Background] The background setting for the edited image.
  54. #
  55. # @param created_at [Integer] The Unix timestamp when the event was created.
  56. #
  57. # @param output_format [Symbol, OpenAI::Models::ImageEditCompletedEvent::OutputFormat] The output format for the edited image.
  58. #
  59. # @param quality [Symbol, OpenAI::Models::ImageEditCompletedEvent::Quality] The quality setting for the edited image.
  60. #
  61. # @param size [Symbol, OpenAI::Models::ImageEditCompletedEvent::Size] The size of the edited image.
  62. #
  63. # @param usage [OpenAI::Models::ImageEditCompletedEvent::Usage] For `gpt-image-1` only, the token usage information for the image generation.
  64. #
  65. # @param type [Symbol, :"image_edit.completed"] The type of the event. Always `image_edit.completed`.
  66. # The background setting for the edited image.
  67. #
  68. # @see OpenAI::Models::ImageEditCompletedEvent#background
  69. 1 module Background
  70. 1 extend OpenAI::Internal::Type::Enum
  71. 1 TRANSPARENT = :transparent
  72. 1 OPAQUE = :opaque
  73. 1 AUTO = :auto
  74. # @!method self.values
  75. # @return [Array<Symbol>]
  76. end
  77. # The output format for the edited image.
  78. #
  79. # @see OpenAI::Models::ImageEditCompletedEvent#output_format
  80. 1 module OutputFormat
  81. 1 extend OpenAI::Internal::Type::Enum
  82. 1 PNG = :png
  83. 1 WEBP = :webp
  84. 1 JPEG = :jpeg
  85. # @!method self.values
  86. # @return [Array<Symbol>]
  87. end
  88. # The quality setting for the edited image.
  89. #
  90. # @see OpenAI::Models::ImageEditCompletedEvent#quality
  91. 1 module Quality
  92. 1 extend OpenAI::Internal::Type::Enum
  93. 1 LOW = :low
  94. 1 MEDIUM = :medium
  95. 1 HIGH = :high
  96. 1 AUTO = :auto
  97. # @!method self.values
  98. # @return [Array<Symbol>]
  99. end
  100. # The size of the edited image.
  101. #
  102. # @see OpenAI::Models::ImageEditCompletedEvent#size
  103. 1 module Size
  104. 1 extend OpenAI::Internal::Type::Enum
  105. 1 SIZE_1024X1024 = :"1024x1024"
  106. 1 SIZE_1024X1536 = :"1024x1536"
  107. 1 SIZE_1536X1024 = :"1536x1024"
  108. 1 AUTO = :auto
  109. # @!method self.values
  110. # @return [Array<Symbol>]
  111. end
  112. # @see OpenAI::Models::ImageEditCompletedEvent#usage
  113. 1 class Usage < OpenAI::Internal::Type::BaseModel
  114. # @!attribute input_tokens
  115. # The number of tokens (images and text) in the input prompt.
  116. #
  117. # @return [Integer]
  118. 1 required :input_tokens, Integer
  119. # @!attribute input_tokens_details
  120. # The input tokens detailed information for the image generation.
  121. #
  122. # @return [OpenAI::Models::ImageEditCompletedEvent::Usage::InputTokensDetails]
  123. 1 required :input_tokens_details, -> { OpenAI::ImageEditCompletedEvent::Usage::InputTokensDetails }
  124. # @!attribute output_tokens
  125. # The number of image tokens in the output image.
  126. #
  127. # @return [Integer]
  128. 1 required :output_tokens, Integer
  129. # @!attribute total_tokens
  130. # The total number of tokens (images and text) used for the image generation.
  131. #
  132. # @return [Integer]
  133. 1 required :total_tokens, Integer
  134. # @!method initialize(input_tokens:, input_tokens_details:, output_tokens:, total_tokens:)
  135. # Some parameter documentations has been truncated, see
  136. # {OpenAI::Models::ImageEditCompletedEvent::Usage} for more details.
  137. #
  138. # For `gpt-image-1` only, the token usage information for the image generation.
  139. #
  140. # @param input_tokens [Integer] The number of tokens (images and text) in the input prompt.
  141. #
  142. # @param input_tokens_details [OpenAI::Models::ImageEditCompletedEvent::Usage::InputTokensDetails] The input tokens detailed information for the image generation.
  143. #
  144. # @param output_tokens [Integer] The number of image tokens in the output image.
  145. #
  146. # @param total_tokens [Integer] The total number of tokens (images and text) used for the image generation.
  147. # @see OpenAI::Models::ImageEditCompletedEvent::Usage#input_tokens_details
  148. 1 class InputTokensDetails < OpenAI::Internal::Type::BaseModel
  149. # @!attribute image_tokens
  150. # The number of image tokens in the input prompt.
  151. #
  152. # @return [Integer]
  153. 1 required :image_tokens, Integer
  154. # @!attribute text_tokens
  155. # The number of text tokens in the input prompt.
  156. #
  157. # @return [Integer]
  158. 1 required :text_tokens, Integer
  159. # @!method initialize(image_tokens:, text_tokens:)
  160. # The input tokens detailed information for the image generation.
  161. #
  162. # @param image_tokens [Integer] The number of image tokens in the input prompt.
  163. #
  164. # @param text_tokens [Integer] The number of text tokens in the input prompt.
  165. end
  166. end
  167. end
  168. end
  169. end

openai-ruby/lib/openai/models/image_edit_params.rb

100.0% lines covered

100.0% branches covered

61 relevant lines. 61 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Images#edit
  5. #
  6. # @see OpenAI::Resources::Images#edit_stream_raw
  7. 1 class ImageEditParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute image
  11. # The image(s) to edit. Must be a supported image file or an array of images.
  12. #
  13. # For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
  14. # 50MB. You can provide up to 16 images.
  15. #
  16. # For `dall-e-2`, you can only provide one image, and it should be a square `png`
  17. # file less than 4MB.
  18. #
  19. # @return [Pathname, StringIO, IO, String, OpenAI::FilePart, Array<Pathname, StringIO, IO, String, OpenAI::FilePart>]
  20. 1 required :image, union: -> { OpenAI::ImageEditParams::Image }
  21. # @!attribute prompt
  22. # A text description of the desired image(s). The maximum length is 1000
  23. # characters for `dall-e-2`, and 32000 characters for `gpt-image-1`.
  24. #
  25. # @return [String]
  26. 1 required :prompt, String
  27. # @!attribute background
  28. # Allows to set transparency for the background of the generated image(s). This
  29. # parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
  30. # `opaque` or `auto` (default value). When `auto` is used, the model will
  31. # automatically determine the best background for the image.
  32. #
  33. # If `transparent`, the output format needs to support transparency, so it should
  34. # be set to either `png` (default value) or `webp`.
  35. #
  36. # @return [Symbol, OpenAI::Models::ImageEditParams::Background, nil]
  37. 1 optional :background, enum: -> { OpenAI::ImageEditParams::Background }, nil?: true
  38. # @!attribute input_fidelity
  39. # Control how much effort the model will exert to match the style and features,
  40. # especially facial features, of input images. This parameter is only supported
  41. # for `gpt-image-1`. Supports `high` and `low`. Defaults to `low`.
  42. #
  43. # @return [Symbol, OpenAI::Models::ImageEditParams::InputFidelity, nil]
  44. 1 optional :input_fidelity, enum: -> { OpenAI::ImageEditParams::InputFidelity }, nil?: true
  45. # @!attribute mask
  46. # An additional image whose fully transparent areas (e.g. where alpha is zero)
  47. # indicate where `image` should be edited. If there are multiple images provided,
  48. # the mask will be applied on the first image. Must be a valid PNG file, less than
  49. # 4MB, and have the same dimensions as `image`.
  50. #
  51. # @return [Pathname, StringIO, IO, String, OpenAI::FilePart, nil]
  52. 1 optional :mask, OpenAI::Internal::Type::FileInput
  53. # @!attribute model
  54. # The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are
  55. # supported. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1`
  56. # is used.
  57. #
  58. # @return [String, Symbol, OpenAI::Models::ImageModel, nil]
  59. 1 optional :model, union: -> { OpenAI::ImageEditParams::Model }, nil?: true
  60. # @!attribute n
  61. # The number of images to generate. Must be between 1 and 10.
  62. #
  63. # @return [Integer, nil]
  64. 1 optional :n, Integer, nil?: true
  65. # @!attribute output_compression
  66. # The compression level (0-100%) for the generated images. This parameter is only
  67. # supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
  68. # defaults to 100.
  69. #
  70. # @return [Integer, nil]
  71. 1 optional :output_compression, Integer, nil?: true
  72. # @!attribute output_format
  73. # The format in which the generated images are returned. This parameter is only
  74. # supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
  75. # default value is `png`.
  76. #
  77. # @return [Symbol, OpenAI::Models::ImageEditParams::OutputFormat, nil]
  78. 1 optional :output_format, enum: -> { OpenAI::ImageEditParams::OutputFormat }, nil?: true
  79. # @!attribute partial_images
  80. # The number of partial images to generate. This parameter is used for streaming
  81. # responses that return partial images. Value must be between 0 and 3. When set to
  82. # 0, the response will be a single image sent in one streaming event.
  83. #
  84. # Note that the final image may be sent before the full number of partial images
  85. # are generated if the full image is generated more quickly.
  86. #
  87. # @return [Integer, nil]
  88. 1 optional :partial_images, Integer, nil?: true
  89. # @!attribute quality
  90. # The quality of the image that will be generated. `high`, `medium` and `low` are
  91. # only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
  92. # Defaults to `auto`.
  93. #
  94. # @return [Symbol, OpenAI::Models::ImageEditParams::Quality, nil]
  95. 1 optional :quality, enum: -> { OpenAI::ImageEditParams::Quality }, nil?: true
  96. # @!attribute response_format
  97. # The format in which the generated images are returned. Must be one of `url` or
  98. # `b64_json`. URLs are only valid for 60 minutes after the image has been
  99. # generated. This parameter is only supported for `dall-e-2`, as `gpt-image-1`
  100. # will always return base64-encoded images.
  101. #
  102. # @return [Symbol, OpenAI::Models::ImageEditParams::ResponseFormat, nil]
  103. 1 optional :response_format, enum: -> { OpenAI::ImageEditParams::ResponseFormat }, nil?: true
  104. # @!attribute size
  105. # The size of the generated images. Must be one of `1024x1024`, `1536x1024`
  106. # (landscape), `1024x1536` (portrait), or `auto` (default value) for
  107. # `gpt-image-1`, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`.
  108. #
  109. # @return [Symbol, OpenAI::Models::ImageEditParams::Size, nil]
  110. 1 optional :size, enum: -> { OpenAI::ImageEditParams::Size }, nil?: true
  111. # @!attribute user
  112. # A unique identifier representing your end-user, which can help OpenAI to monitor
  113. # and detect abuse.
  114. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
  115. #
  116. # @return [String, nil]
  117. 1 optional :user, String
  118. # @!method initialize(image:, prompt:, background: nil, input_fidelity: nil, mask: nil, model: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, user: nil, request_options: {})
  119. # Some parameter documentations has been truncated, see
  120. # {OpenAI::Models::ImageEditParams} for more details.
  121. #
  122. # @param image [Pathname, StringIO, IO, String, OpenAI::FilePart, Array<Pathname, StringIO, IO, String, OpenAI::FilePart>] The image(s) to edit. Must be a supported image file or an array of images.
  123. #
  124. # @param prompt [String] A text description of the desired image(s). The maximum length is 1000 character
  125. #
  126. # @param background [Symbol, OpenAI::Models::ImageEditParams::Background, nil] Allows to set transparency for the background of the generated image(s).
  127. #
  128. # @param input_fidelity [Symbol, OpenAI::Models::ImageEditParams::InputFidelity, nil] Control how much effort the model will exert to match the style and features,
  129. #
  130. # @param mask [Pathname, StringIO, IO, String, OpenAI::FilePart] An additional image whose fully transparent areas (e.g. where alpha is zero) ind
  131. #
  132. # @param model [String, Symbol, OpenAI::Models::ImageModel, nil] The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are sup
  133. #
  134. # @param n [Integer, nil] The number of images to generate. Must be between 1 and 10.
  135. #
  136. # @param output_compression [Integer, nil] The compression level (0-100%) for the generated images. This parameter
  137. #
  138. # @param output_format [Symbol, OpenAI::Models::ImageEditParams::OutputFormat, nil] The format in which the generated images are returned. This parameter is
  139. #
  140. # @param partial_images [Integer, nil] The number of partial images to generate. This parameter is used for
  141. #
  142. # @param quality [Symbol, OpenAI::Models::ImageEditParams::Quality, nil] The quality of the image that will be generated. `high`, `medium` and `low` are
  143. #
  144. # @param response_format [Symbol, OpenAI::Models::ImageEditParams::ResponseFormat, nil] The format in which the generated images are returned. Must be one of `url` or `
  145. #
  146. # @param size [Symbol, OpenAI::Models::ImageEditParams::Size, nil] The size of the generated images. Must be one of `1024x1024`, `1536x1024` (lands
  147. #
  148. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  149. #
  150. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  151. # The image(s) to edit. Must be a supported image file or an array of images.
  152. #
  153. # For `gpt-image-1`, each image should be a `png`, `webp`, or `jpg` file less than
  154. # 50MB. You can provide up to 16 images.
  155. #
  156. # For `dall-e-2`, you can only provide one image, and it should be a square `png`
  157. # file less than 4MB.
  158. 1 module Image
  159. 1 extend OpenAI::Internal::Type::Union
  160. 1 variant OpenAI::Internal::Type::FileInput
  161. 1 variant -> { OpenAI::Models::ImageEditParams::Image::StringArray }
  162. # @!method self.variants
  163. # @return [Array(StringIO, Array<StringIO>)]
  164. # @type [OpenAI::Internal::Type::Converter]
  165. 1 StringArray = OpenAI::Internal::Type::ArrayOf[OpenAI::Internal::Type::FileInput]
  166. end
  167. # Allows to set transparency for the background of the generated image(s). This
  168. # parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
  169. # `opaque` or `auto` (default value). When `auto` is used, the model will
  170. # automatically determine the best background for the image.
  171. #
  172. # If `transparent`, the output format needs to support transparency, so it should
  173. # be set to either `png` (default value) or `webp`.
  174. 1 module Background
  175. 1 extend OpenAI::Internal::Type::Enum
  176. 1 TRANSPARENT = :transparent
  177. 1 OPAQUE = :opaque
  178. 1 AUTO = :auto
  179. # @!method self.values
  180. # @return [Array<Symbol>]
  181. end
  182. # Control how much effort the model will exert to match the style and features,
  183. # especially facial features, of input images. This parameter is only supported
  184. # for `gpt-image-1`. Supports `high` and `low`. Defaults to `low`.
  185. 1 module InputFidelity
  186. 1 extend OpenAI::Internal::Type::Enum
  187. 1 HIGH = :high
  188. 1 LOW = :low
  189. # @!method self.values
  190. # @return [Array<Symbol>]
  191. end
  192. # The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are
  193. # supported. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1`
  194. # is used.
  195. 1 module Model
  196. 1 extend OpenAI::Internal::Type::Union
  197. 1 variant String
  198. # The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are supported. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1` is used.
  199. 1 variant enum: -> { OpenAI::ImageModel }
  200. # @!method self.variants
  201. # @return [Array(String, Symbol, OpenAI::Models::ImageModel)]
  202. end
  203. # The format in which the generated images are returned. This parameter is only
  204. # supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`. The
  205. # default value is `png`.
  206. 1 module OutputFormat
  207. 1 extend OpenAI::Internal::Type::Enum
  208. 1 PNG = :png
  209. 1 JPEG = :jpeg
  210. 1 WEBP = :webp
  211. # @!method self.values
  212. # @return [Array<Symbol>]
  213. end
  214. # The quality of the image that will be generated. `high`, `medium` and `low` are
  215. # only supported for `gpt-image-1`. `dall-e-2` only supports `standard` quality.
  216. # Defaults to `auto`.
  217. 1 module Quality
  218. 1 extend OpenAI::Internal::Type::Enum
  219. 1 STANDARD = :standard
  220. 1 LOW = :low
  221. 1 MEDIUM = :medium
  222. 1 HIGH = :high
  223. 1 AUTO = :auto
  224. # @!method self.values
  225. # @return [Array<Symbol>]
  226. end
  227. # The format in which the generated images are returned. Must be one of `url` or
  228. # `b64_json`. URLs are only valid for 60 minutes after the image has been
  229. # generated. This parameter is only supported for `dall-e-2`, as `gpt-image-1`
  230. # will always return base64-encoded images.
  231. 1 module ResponseFormat
  232. 1 extend OpenAI::Internal::Type::Enum
  233. 1 URL = :url
  234. 1 B64_JSON = :b64_json
  235. # @!method self.values
  236. # @return [Array<Symbol>]
  237. end
  238. # The size of the generated images. Must be one of `1024x1024`, `1536x1024`
  239. # (landscape), `1024x1536` (portrait), or `auto` (default value) for
  240. # `gpt-image-1`, and one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`.
  241. 1 module Size
  242. 1 extend OpenAI::Internal::Type::Enum
  243. 1 SIZE_256X256 = :"256x256"
  244. 1 SIZE_512X512 = :"512x512"
  245. 1 SIZE_1024X1024 = :"1024x1024"
  246. 1 SIZE_1536X1024 = :"1536x1024"
  247. 1 SIZE_1024X1536 = :"1024x1536"
  248. 1 AUTO = :auto
  249. # @!method self.values
  250. # @return [Array<Symbol>]
  251. end
  252. end
  253. end
  254. end

openai-ruby/lib/openai/models/image_edit_partial_image_event.rb

100.0% lines covered

100.0% branches covered

33 relevant lines. 33 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ImageEditPartialImageEvent < OpenAI::Internal::Type::BaseModel
  5. # @!attribute b64_json
  6. # Base64-encoded partial image data, suitable for rendering as an image.
  7. #
  8. # @return [String]
  9. 1 required :b64_json, String
  10. # @!attribute background
  11. # The background setting for the requested edited image.
  12. #
  13. # @return [Symbol, OpenAI::Models::ImageEditPartialImageEvent::Background]
  14. 1 required :background, enum: -> { OpenAI::ImageEditPartialImageEvent::Background }
  15. # @!attribute created_at
  16. # The Unix timestamp when the event was created.
  17. #
  18. # @return [Integer]
  19. 1 required :created_at, Integer
  20. # @!attribute output_format
  21. # The output format for the requested edited image.
  22. #
  23. # @return [Symbol, OpenAI::Models::ImageEditPartialImageEvent::OutputFormat]
  24. 1 required :output_format, enum: -> { OpenAI::ImageEditPartialImageEvent::OutputFormat }
  25. # @!attribute partial_image_index
  26. # 0-based index for the partial image (streaming).
  27. #
  28. # @return [Integer]
  29. 1 required :partial_image_index, Integer
  30. # @!attribute quality
  31. # The quality setting for the requested edited image.
  32. #
  33. # @return [Symbol, OpenAI::Models::ImageEditPartialImageEvent::Quality]
  34. 1 required :quality, enum: -> { OpenAI::ImageEditPartialImageEvent::Quality }
  35. # @!attribute size
  36. # The size of the requested edited image.
  37. #
  38. # @return [Symbol, OpenAI::Models::ImageEditPartialImageEvent::Size]
  39. 1 required :size, enum: -> { OpenAI::ImageEditPartialImageEvent::Size }
  40. # @!attribute type
  41. # The type of the event. Always `image_edit.partial_image`.
  42. #
  43. # @return [Symbol, :"image_edit.partial_image"]
  44. 1 required :type, const: :"image_edit.partial_image"
  45. # @!method initialize(b64_json:, background:, created_at:, output_format:, partial_image_index:, quality:, size:, type: :"image_edit.partial_image")
  46. # Some parameter documentations has been truncated, see
  47. # {OpenAI::Models::ImageEditPartialImageEvent} for more details.
  48. #
  49. # Emitted when a partial image is available during image editing streaming.
  50. #
  51. # @param b64_json [String] Base64-encoded partial image data, suitable for rendering as an image.
  52. #
  53. # @param background [Symbol, OpenAI::Models::ImageEditPartialImageEvent::Background] The background setting for the requested edited image.
  54. #
  55. # @param created_at [Integer] The Unix timestamp when the event was created.
  56. #
  57. # @param output_format [Symbol, OpenAI::Models::ImageEditPartialImageEvent::OutputFormat] The output format for the requested edited image.
  58. #
  59. # @param partial_image_index [Integer] 0-based index for the partial image (streaming).
  60. #
  61. # @param quality [Symbol, OpenAI::Models::ImageEditPartialImageEvent::Quality] The quality setting for the requested edited image.
  62. #
  63. # @param size [Symbol, OpenAI::Models::ImageEditPartialImageEvent::Size] The size of the requested edited image.
  64. #
  65. # @param type [Symbol, :"image_edit.partial_image"] The type of the event. Always `image_edit.partial_image`.
  66. # The background setting for the requested edited image.
  67. #
  68. # @see OpenAI::Models::ImageEditPartialImageEvent#background
  69. 1 module Background
  70. 1 extend OpenAI::Internal::Type::Enum
  71. 1 TRANSPARENT = :transparent
  72. 1 OPAQUE = :opaque
  73. 1 AUTO = :auto
  74. # @!method self.values
  75. # @return [Array<Symbol>]
  76. end
  77. # The output format for the requested edited image.
  78. #
  79. # @see OpenAI::Models::ImageEditPartialImageEvent#output_format
  80. 1 module OutputFormat
  81. 1 extend OpenAI::Internal::Type::Enum
  82. 1 PNG = :png
  83. 1 WEBP = :webp
  84. 1 JPEG = :jpeg
  85. # @!method self.values
  86. # @return [Array<Symbol>]
  87. end
  88. # The quality setting for the requested edited image.
  89. #
  90. # @see OpenAI::Models::ImageEditPartialImageEvent#quality
  91. 1 module Quality
  92. 1 extend OpenAI::Internal::Type::Enum
  93. 1 LOW = :low
  94. 1 MEDIUM = :medium
  95. 1 HIGH = :high
  96. 1 AUTO = :auto
  97. # @!method self.values
  98. # @return [Array<Symbol>]
  99. end
  100. # The size of the requested edited image.
  101. #
  102. # @see OpenAI::Models::ImageEditPartialImageEvent#size
  103. 1 module Size
  104. 1 extend OpenAI::Internal::Type::Enum
  105. 1 SIZE_1024X1024 = :"1024x1024"
  106. 1 SIZE_1024X1536 = :"1024x1536"
  107. 1 SIZE_1536X1024 = :"1536x1024"
  108. 1 AUTO = :auto
  109. # @!method self.values
  110. # @return [Array<Symbol>]
  111. end
  112. end
  113. end
  114. end

openai-ruby/lib/openai/models/image_edit_stream_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # Emitted when a partial image is available during image editing streaming.
  5. 1 module ImageEditStreamEvent
  6. 1 extend OpenAI::Internal::Type::Union
  7. 1 discriminator :type
  8. # Emitted when a partial image is available during image editing streaming.
  9. 1 variant :"image_edit.partial_image", -> { OpenAI::ImageEditPartialImageEvent }
  10. # Emitted when image editing has completed and the final image is available.
  11. 1 variant :"image_edit.completed", -> { OpenAI::ImageEditCompletedEvent }
  12. # @!method self.variants
  13. # @return [Array(OpenAI::Models::ImageEditPartialImageEvent, OpenAI::Models::ImageEditCompletedEvent)]
  14. end
  15. end
  16. end

openai-ruby/lib/openai/models/image_gen_completed_event.rb

100.0% lines covered

100.0% branches covered

41 relevant lines. 41 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ImageGenCompletedEvent < OpenAI::Internal::Type::BaseModel
  5. # @!attribute b64_json
  6. # Base64-encoded image data, suitable for rendering as an image.
  7. #
  8. # @return [String]
  9. 1 required :b64_json, String
  10. # @!attribute background
  11. # The background setting for the generated image.
  12. #
  13. # @return [Symbol, OpenAI::Models::ImageGenCompletedEvent::Background]
  14. 1 required :background, enum: -> { OpenAI::ImageGenCompletedEvent::Background }
  15. # @!attribute created_at
  16. # The Unix timestamp when the event was created.
  17. #
  18. # @return [Integer]
  19. 1 required :created_at, Integer
  20. # @!attribute output_format
  21. # The output format for the generated image.
  22. #
  23. # @return [Symbol, OpenAI::Models::ImageGenCompletedEvent::OutputFormat]
  24. 1 required :output_format, enum: -> { OpenAI::ImageGenCompletedEvent::OutputFormat }
  25. # @!attribute quality
  26. # The quality setting for the generated image.
  27. #
  28. # @return [Symbol, OpenAI::Models::ImageGenCompletedEvent::Quality]
  29. 1 required :quality, enum: -> { OpenAI::ImageGenCompletedEvent::Quality }
  30. # @!attribute size
  31. # The size of the generated image.
  32. #
  33. # @return [Symbol, OpenAI::Models::ImageGenCompletedEvent::Size]
  34. 1 required :size, enum: -> { OpenAI::ImageGenCompletedEvent::Size }
  35. # @!attribute type
  36. # The type of the event. Always `image_generation.completed`.
  37. #
  38. # @return [Symbol, :"image_generation.completed"]
  39. 1 required :type, const: :"image_generation.completed"
  40. # @!attribute usage
  41. # For `gpt-image-1` only, the token usage information for the image generation.
  42. #
  43. # @return [OpenAI::Models::ImageGenCompletedEvent::Usage]
  44. 1 required :usage, -> { OpenAI::ImageGenCompletedEvent::Usage }
  45. # @!method initialize(b64_json:, background:, created_at:, output_format:, quality:, size:, usage:, type: :"image_generation.completed")
  46. # Some parameter documentations has been truncated, see
  47. # {OpenAI::Models::ImageGenCompletedEvent} for more details.
  48. #
  49. # Emitted when image generation has completed and the final image is available.
  50. #
  51. # @param b64_json [String] Base64-encoded image data, suitable for rendering as an image.
  52. #
  53. # @param background [Symbol, OpenAI::Models::ImageGenCompletedEvent::Background] The background setting for the generated image.
  54. #
  55. # @param created_at [Integer] The Unix timestamp when the event was created.
  56. #
  57. # @param output_format [Symbol, OpenAI::Models::ImageGenCompletedEvent::OutputFormat] The output format for the generated image.
  58. #
  59. # @param quality [Symbol, OpenAI::Models::ImageGenCompletedEvent::Quality] The quality setting for the generated image.
  60. #
  61. # @param size [Symbol, OpenAI::Models::ImageGenCompletedEvent::Size] The size of the generated image.
  62. #
  63. # @param usage [OpenAI::Models::ImageGenCompletedEvent::Usage] For `gpt-image-1` only, the token usage information for the image generation.
  64. #
  65. # @param type [Symbol, :"image_generation.completed"] The type of the event. Always `image_generation.completed`.
  66. # The background setting for the generated image.
  67. #
  68. # @see OpenAI::Models::ImageGenCompletedEvent#background
  69. 1 module Background
  70. 1 extend OpenAI::Internal::Type::Enum
  71. 1 TRANSPARENT = :transparent
  72. 1 OPAQUE = :opaque
  73. 1 AUTO = :auto
  74. # @!method self.values
  75. # @return [Array<Symbol>]
  76. end
  77. # The output format for the generated image.
  78. #
  79. # @see OpenAI::Models::ImageGenCompletedEvent#output_format
  80. 1 module OutputFormat
  81. 1 extend OpenAI::Internal::Type::Enum
  82. 1 PNG = :png
  83. 1 WEBP = :webp
  84. 1 JPEG = :jpeg
  85. # @!method self.values
  86. # @return [Array<Symbol>]
  87. end
  88. # The quality setting for the generated image.
  89. #
  90. # @see OpenAI::Models::ImageGenCompletedEvent#quality
  91. 1 module Quality
  92. 1 extend OpenAI::Internal::Type::Enum
  93. 1 LOW = :low
  94. 1 MEDIUM = :medium
  95. 1 HIGH = :high
  96. 1 AUTO = :auto
  97. # @!method self.values
  98. # @return [Array<Symbol>]
  99. end
  100. # The size of the generated image.
  101. #
  102. # @see OpenAI::Models::ImageGenCompletedEvent#size
  103. 1 module Size
  104. 1 extend OpenAI::Internal::Type::Enum
  105. 1 SIZE_1024X1024 = :"1024x1024"
  106. 1 SIZE_1024X1536 = :"1024x1536"
  107. 1 SIZE_1536X1024 = :"1536x1024"
  108. 1 AUTO = :auto
  109. # @!method self.values
  110. # @return [Array<Symbol>]
  111. end
  112. # @see OpenAI::Models::ImageGenCompletedEvent#usage
  113. 1 class Usage < OpenAI::Internal::Type::BaseModel
  114. # @!attribute input_tokens
  115. # The number of tokens (images and text) in the input prompt.
  116. #
  117. # @return [Integer]
  118. 1 required :input_tokens, Integer
  119. # @!attribute input_tokens_details
  120. # The input tokens detailed information for the image generation.
  121. #
  122. # @return [OpenAI::Models::ImageGenCompletedEvent::Usage::InputTokensDetails]
  123. 1 required :input_tokens_details, -> { OpenAI::ImageGenCompletedEvent::Usage::InputTokensDetails }
  124. # @!attribute output_tokens
  125. # The number of image tokens in the output image.
  126. #
  127. # @return [Integer]
  128. 1 required :output_tokens, Integer
  129. # @!attribute total_tokens
  130. # The total number of tokens (images and text) used for the image generation.
  131. #
  132. # @return [Integer]
  133. 1 required :total_tokens, Integer
  134. # @!method initialize(input_tokens:, input_tokens_details:, output_tokens:, total_tokens:)
  135. # Some parameter documentations has been truncated, see
  136. # {OpenAI::Models::ImageGenCompletedEvent::Usage} for more details.
  137. #
  138. # For `gpt-image-1` only, the token usage information for the image generation.
  139. #
  140. # @param input_tokens [Integer] The number of tokens (images and text) in the input prompt.
  141. #
  142. # @param input_tokens_details [OpenAI::Models::ImageGenCompletedEvent::Usage::InputTokensDetails] The input tokens detailed information for the image generation.
  143. #
  144. # @param output_tokens [Integer] The number of image tokens in the output image.
  145. #
  146. # @param total_tokens [Integer] The total number of tokens (images and text) used for the image generation.
  147. # @see OpenAI::Models::ImageGenCompletedEvent::Usage#input_tokens_details
  148. 1 class InputTokensDetails < OpenAI::Internal::Type::BaseModel
  149. # @!attribute image_tokens
  150. # The number of image tokens in the input prompt.
  151. #
  152. # @return [Integer]
  153. 1 required :image_tokens, Integer
  154. # @!attribute text_tokens
  155. # The number of text tokens in the input prompt.
  156. #
  157. # @return [Integer]
  158. 1 required :text_tokens, Integer
  159. # @!method initialize(image_tokens:, text_tokens:)
  160. # The input tokens detailed information for the image generation.
  161. #
  162. # @param image_tokens [Integer] The number of image tokens in the input prompt.
  163. #
  164. # @param text_tokens [Integer] The number of text tokens in the input prompt.
  165. end
  166. end
  167. end
  168. end
  169. end

openai-ruby/lib/openai/models/image_gen_partial_image_event.rb

100.0% lines covered

100.0% branches covered

33 relevant lines. 33 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ImageGenPartialImageEvent < OpenAI::Internal::Type::BaseModel
  5. # @!attribute b64_json
  6. # Base64-encoded partial image data, suitable for rendering as an image.
  7. #
  8. # @return [String]
  9. 1 required :b64_json, String
  10. # @!attribute background
  11. # The background setting for the requested image.
  12. #
  13. # @return [Symbol, OpenAI::Models::ImageGenPartialImageEvent::Background]
  14. 1 required :background, enum: -> { OpenAI::ImageGenPartialImageEvent::Background }
  15. # @!attribute created_at
  16. # The Unix timestamp when the event was created.
  17. #
  18. # @return [Integer]
  19. 1 required :created_at, Integer
  20. # @!attribute output_format
  21. # The output format for the requested image.
  22. #
  23. # @return [Symbol, OpenAI::Models::ImageGenPartialImageEvent::OutputFormat]
  24. 1 required :output_format, enum: -> { OpenAI::ImageGenPartialImageEvent::OutputFormat }
  25. # @!attribute partial_image_index
  26. # 0-based index for the partial image (streaming).
  27. #
  28. # @return [Integer]
  29. 1 required :partial_image_index, Integer
  30. # @!attribute quality
  31. # The quality setting for the requested image.
  32. #
  33. # @return [Symbol, OpenAI::Models::ImageGenPartialImageEvent::Quality]
  34. 1 required :quality, enum: -> { OpenAI::ImageGenPartialImageEvent::Quality }
  35. # @!attribute size
  36. # The size of the requested image.
  37. #
  38. # @return [Symbol, OpenAI::Models::ImageGenPartialImageEvent::Size]
  39. 1 required :size, enum: -> { OpenAI::ImageGenPartialImageEvent::Size }
  40. # @!attribute type
  41. # The type of the event. Always `image_generation.partial_image`.
  42. #
  43. # @return [Symbol, :"image_generation.partial_image"]
  44. 1 required :type, const: :"image_generation.partial_image"
  45. # @!method initialize(b64_json:, background:, created_at:, output_format:, partial_image_index:, quality:, size:, type: :"image_generation.partial_image")
  46. # Some parameter documentations has been truncated, see
  47. # {OpenAI::Models::ImageGenPartialImageEvent} for more details.
  48. #
  49. # Emitted when a partial image is available during image generation streaming.
  50. #
  51. # @param b64_json [String] Base64-encoded partial image data, suitable for rendering as an image.
  52. #
  53. # @param background [Symbol, OpenAI::Models::ImageGenPartialImageEvent::Background] The background setting for the requested image.
  54. #
  55. # @param created_at [Integer] The Unix timestamp when the event was created.
  56. #
  57. # @param output_format [Symbol, OpenAI::Models::ImageGenPartialImageEvent::OutputFormat] The output format for the requested image.
  58. #
  59. # @param partial_image_index [Integer] 0-based index for the partial image (streaming).
  60. #
  61. # @param quality [Symbol, OpenAI::Models::ImageGenPartialImageEvent::Quality] The quality setting for the requested image.
  62. #
  63. # @param size [Symbol, OpenAI::Models::ImageGenPartialImageEvent::Size] The size of the requested image.
  64. #
  65. # @param type [Symbol, :"image_generation.partial_image"] The type of the event. Always `image_generation.partial_image`.
  66. # The background setting for the requested image.
  67. #
  68. # @see OpenAI::Models::ImageGenPartialImageEvent#background
  69. 1 module Background
  70. 1 extend OpenAI::Internal::Type::Enum
  71. 1 TRANSPARENT = :transparent
  72. 1 OPAQUE = :opaque
  73. 1 AUTO = :auto
  74. # @!method self.values
  75. # @return [Array<Symbol>]
  76. end
  77. # The output format for the requested image.
  78. #
  79. # @see OpenAI::Models::ImageGenPartialImageEvent#output_format
  80. 1 module OutputFormat
  81. 1 extend OpenAI::Internal::Type::Enum
  82. 1 PNG = :png
  83. 1 WEBP = :webp
  84. 1 JPEG = :jpeg
  85. # @!method self.values
  86. # @return [Array<Symbol>]
  87. end
  88. # The quality setting for the requested image.
  89. #
  90. # @see OpenAI::Models::ImageGenPartialImageEvent#quality
  91. 1 module Quality
  92. 1 extend OpenAI::Internal::Type::Enum
  93. 1 LOW = :low
  94. 1 MEDIUM = :medium
  95. 1 HIGH = :high
  96. 1 AUTO = :auto
  97. # @!method self.values
  98. # @return [Array<Symbol>]
  99. end
  100. # The size of the requested image.
  101. #
  102. # @see OpenAI::Models::ImageGenPartialImageEvent#size
  103. 1 module Size
  104. 1 extend OpenAI::Internal::Type::Enum
  105. 1 SIZE_1024X1024 = :"1024x1024"
  106. 1 SIZE_1024X1536 = :"1024x1536"
  107. 1 SIZE_1536X1024 = :"1536x1024"
  108. 1 AUTO = :auto
  109. # @!method self.values
  110. # @return [Array<Symbol>]
  111. end
  112. end
  113. end
  114. end

openai-ruby/lib/openai/models/image_gen_stream_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # Emitted when a partial image is available during image generation streaming.
  5. 1 module ImageGenStreamEvent
  6. 1 extend OpenAI::Internal::Type::Union
  7. 1 discriminator :type
  8. # Emitted when a partial image is available during image generation streaming.
  9. 1 variant :"image_generation.partial_image", -> { OpenAI::ImageGenPartialImageEvent }
  10. # Emitted when image generation has completed and the final image is available.
  11. 1 variant :"image_generation.completed", -> { OpenAI::ImageGenCompletedEvent }
  12. # @!method self.variants
  13. # @return [Array(OpenAI::Models::ImageGenPartialImageEvent, OpenAI::Models::ImageGenCompletedEvent)]
  14. end
  15. end
  16. end

openai-ruby/lib/openai/models/image_generate_params.rb

100.0% lines covered

100.0% branches covered

62 relevant lines. 62 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Images#generate
  5. #
  6. # @see OpenAI::Resources::Images#generate_stream_raw
  7. 1 class ImageGenerateParams < OpenAI::Internal::Type::BaseModel
  8. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  9. 1 include OpenAI::Internal::Type::RequestParameters
  10. # @!attribute prompt
  11. # A text description of the desired image(s). The maximum length is 32000
  12. # characters for `gpt-image-1`, 1000 characters for `dall-e-2` and 4000 characters
  13. # for `dall-e-3`.
  14. #
  15. # @return [String]
  16. 1 required :prompt, String
  17. # @!attribute background
  18. # Allows to set transparency for the background of the generated image(s). This
  19. # parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
  20. # `opaque` or `auto` (default value). When `auto` is used, the model will
  21. # automatically determine the best background for the image.
  22. #
  23. # If `transparent`, the output format needs to support transparency, so it should
  24. # be set to either `png` (default value) or `webp`.
  25. #
  26. # @return [Symbol, OpenAI::Models::ImageGenerateParams::Background, nil]
  27. 1 optional :background, enum: -> { OpenAI::ImageGenerateParams::Background }, nil?: true
  28. # @!attribute model
  29. # The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or
  30. # `gpt-image-1`. Defaults to `dall-e-2` unless a parameter specific to
  31. # `gpt-image-1` is used.
  32. #
  33. # @return [String, Symbol, OpenAI::Models::ImageModel, nil]
  34. 1 optional :model, union: -> { OpenAI::ImageGenerateParams::Model }, nil?: true
  35. # @!attribute moderation
  36. # Control the content-moderation level for images generated by `gpt-image-1`. Must
  37. # be either `low` for less restrictive filtering or `auto` (default value).
  38. #
  39. # @return [Symbol, OpenAI::Models::ImageGenerateParams::Moderation, nil]
  40. 1 optional :moderation, enum: -> { OpenAI::ImageGenerateParams::Moderation }, nil?: true
  41. # @!attribute n
  42. # The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
  43. # `n=1` is supported.
  44. #
  45. # @return [Integer, nil]
  46. 1 optional :n, Integer, nil?: true
  47. # @!attribute output_compression
  48. # The compression level (0-100%) for the generated images. This parameter is only
  49. # supported for `gpt-image-1` with the `webp` or `jpeg` output formats, and
  50. # defaults to 100.
  51. #
  52. # @return [Integer, nil]
  53. 1 optional :output_compression, Integer, nil?: true
  54. # @!attribute output_format
  55. # The format in which the generated images are returned. This parameter is only
  56. # supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`.
  57. #
  58. # @return [Symbol, OpenAI::Models::ImageGenerateParams::OutputFormat, nil]
  59. 1 optional :output_format, enum: -> { OpenAI::ImageGenerateParams::OutputFormat }, nil?: true
  60. # @!attribute partial_images
  61. # The number of partial images to generate. This parameter is used for streaming
  62. # responses that return partial images. Value must be between 0 and 3. When set to
  63. # 0, the response will be a single image sent in one streaming event.
  64. #
  65. # Note that the final image may be sent before the full number of partial images
  66. # are generated if the full image is generated more quickly.
  67. #
  68. # @return [Integer, nil]
  69. 1 optional :partial_images, Integer, nil?: true
  70. # @!attribute quality
  71. # The quality of the image that will be generated.
  72. #
  73. # - `auto` (default value) will automatically select the best quality for the
  74. # given model.
  75. # - `high`, `medium` and `low` are supported for `gpt-image-1`.
  76. # - `hd` and `standard` are supported for `dall-e-3`.
  77. # - `standard` is the only option for `dall-e-2`.
  78. #
  79. # @return [Symbol, OpenAI::Models::ImageGenerateParams::Quality, nil]
  80. 1 optional :quality, enum: -> { OpenAI::ImageGenerateParams::Quality }, nil?: true
  81. # @!attribute response_format
  82. # The format in which generated images with `dall-e-2` and `dall-e-3` are
  83. # returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes
  84. # after the image has been generated. This parameter isn't supported for
  85. # `gpt-image-1` which will always return base64-encoded images.
  86. #
  87. # @return [Symbol, OpenAI::Models::ImageGenerateParams::ResponseFormat, nil]
  88. 1 optional :response_format, enum: -> { OpenAI::ImageGenerateParams::ResponseFormat }, nil?: true
  89. # @!attribute size
  90. # The size of the generated images. Must be one of `1024x1024`, `1536x1024`
  91. # (landscape), `1024x1536` (portrait), or `auto` (default value) for
  92. # `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and
  93. # one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.
  94. #
  95. # @return [Symbol, OpenAI::Models::ImageGenerateParams::Size, nil]
  96. 1 optional :size, enum: -> { OpenAI::ImageGenerateParams::Size }, nil?: true
  97. # @!attribute style
  98. # The style of the generated images. This parameter is only supported for
  99. # `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean
  100. # towards generating hyper-real and dramatic images. Natural causes the model to
  101. # produce more natural, less hyper-real looking images.
  102. #
  103. # @return [Symbol, OpenAI::Models::ImageGenerateParams::Style, nil]
  104. 1 optional :style, enum: -> { OpenAI::ImageGenerateParams::Style }, nil?: true
  105. # @!attribute user
  106. # A unique identifier representing your end-user, which can help OpenAI to monitor
  107. # and detect abuse.
  108. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#end-user-ids).
  109. #
  110. # @return [String, nil]
  111. 1 optional :user, String
  112. # @!method initialize(prompt:, background: nil, model: nil, moderation: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, style: nil, user: nil, request_options: {})
  113. # Some parameter documentations has been truncated, see
  114. # {OpenAI::Models::ImageGenerateParams} for more details.
  115. #
  116. # @param prompt [String] A text description of the desired image(s). The maximum length is 32000 characte
  117. #
  118. # @param background [Symbol, OpenAI::Models::ImageGenerateParams::Background, nil] Allows to set transparency for the background of the generated image(s).
  119. #
  120. # @param model [String, Symbol, OpenAI::Models::ImageModel, nil] The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or `gpt-im
  121. #
  122. # @param moderation [Symbol, OpenAI::Models::ImageGenerateParams::Moderation, nil] Control the content-moderation level for images generated by `gpt-image-1`. Must
  123. #
  124. # @param n [Integer, nil] The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
  125. #
  126. # @param output_compression [Integer, nil] The compression level (0-100%) for the generated images. This parameter is only
  127. #
  128. # @param output_format [Symbol, OpenAI::Models::ImageGenerateParams::OutputFormat, nil] The format in which the generated images are returned. This parameter is only su
  129. #
  130. # @param partial_images [Integer, nil] The number of partial images to generate. This parameter is used for
  131. #
  132. # @param quality [Symbol, OpenAI::Models::ImageGenerateParams::Quality, nil] The quality of the image that will be generated.
  133. #
  134. # @param response_format [Symbol, OpenAI::Models::ImageGenerateParams::ResponseFormat, nil] The format in which generated images with `dall-e-2` and `dall-e-3` are returned
  135. #
  136. # @param size [Symbol, OpenAI::Models::ImageGenerateParams::Size, nil] The size of the generated images. Must be one of `1024x1024`, `1536x1024` (lands
  137. #
  138. # @param style [Symbol, OpenAI::Models::ImageGenerateParams::Style, nil] The style of the generated images. This parameter is only supported for `dall-e-
  139. #
  140. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  141. #
  142. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  143. # Allows to set transparency for the background of the generated image(s). This
  144. # parameter is only supported for `gpt-image-1`. Must be one of `transparent`,
  145. # `opaque` or `auto` (default value). When `auto` is used, the model will
  146. # automatically determine the best background for the image.
  147. #
  148. # If `transparent`, the output format needs to support transparency, so it should
  149. # be set to either `png` (default value) or `webp`.
  150. 1 module Background
  151. 1 extend OpenAI::Internal::Type::Enum
  152. 1 TRANSPARENT = :transparent
  153. 1 OPAQUE = :opaque
  154. 1 AUTO = :auto
  155. # @!method self.values
  156. # @return [Array<Symbol>]
  157. end
  158. # The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or
  159. # `gpt-image-1`. Defaults to `dall-e-2` unless a parameter specific to
  160. # `gpt-image-1` is used.
  161. 1 module Model
  162. 1 extend OpenAI::Internal::Type::Union
  163. 1 variant String
  164. # The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or `gpt-image-1`. Defaults to `dall-e-2` unless a parameter specific to `gpt-image-1` is used.
  165. 1 variant enum: -> { OpenAI::ImageModel }
  166. # @!method self.variants
  167. # @return [Array(String, Symbol, OpenAI::Models::ImageModel)]
  168. end
  169. # Control the content-moderation level for images generated by `gpt-image-1`. Must
  170. # be either `low` for less restrictive filtering or `auto` (default value).
  171. 1 module Moderation
  172. 1 extend OpenAI::Internal::Type::Enum
  173. 1 LOW = :low
  174. 1 AUTO = :auto
  175. # @!method self.values
  176. # @return [Array<Symbol>]
  177. end
  178. # The format in which the generated images are returned. This parameter is only
  179. # supported for `gpt-image-1`. Must be one of `png`, `jpeg`, or `webp`.
  180. 1 module OutputFormat
  181. 1 extend OpenAI::Internal::Type::Enum
  182. 1 PNG = :png
  183. 1 JPEG = :jpeg
  184. 1 WEBP = :webp
  185. # @!method self.values
  186. # @return [Array<Symbol>]
  187. end
  188. # The quality of the image that will be generated.
  189. #
  190. # - `auto` (default value) will automatically select the best quality for the
  191. # given model.
  192. # - `high`, `medium` and `low` are supported for `gpt-image-1`.
  193. # - `hd` and `standard` are supported for `dall-e-3`.
  194. # - `standard` is the only option for `dall-e-2`.
  195. 1 module Quality
  196. 1 extend OpenAI::Internal::Type::Enum
  197. 1 STANDARD = :standard
  198. 1 HD = :hd
  199. 1 LOW = :low
  200. 1 MEDIUM = :medium
  201. 1 HIGH = :high
  202. 1 AUTO = :auto
  203. # @!method self.values
  204. # @return [Array<Symbol>]
  205. end
  206. # The format in which generated images with `dall-e-2` and `dall-e-3` are
  207. # returned. Must be one of `url` or `b64_json`. URLs are only valid for 60 minutes
  208. # after the image has been generated. This parameter isn't supported for
  209. # `gpt-image-1` which will always return base64-encoded images.
  210. 1 module ResponseFormat
  211. 1 extend OpenAI::Internal::Type::Enum
  212. 1 URL = :url
  213. 1 B64_JSON = :b64_json
  214. # @!method self.values
  215. # @return [Array<Symbol>]
  216. end
  217. # The size of the generated images. Must be one of `1024x1024`, `1536x1024`
  218. # (landscape), `1024x1536` (portrait), or `auto` (default value) for
  219. # `gpt-image-1`, one of `256x256`, `512x512`, or `1024x1024` for `dall-e-2`, and
  220. # one of `1024x1024`, `1792x1024`, or `1024x1792` for `dall-e-3`.
  221. 1 module Size
  222. 1 extend OpenAI::Internal::Type::Enum
  223. 1 AUTO = :auto
  224. 1 SIZE_1024X1024 = :"1024x1024"
  225. 1 SIZE_1536X1024 = :"1536x1024"
  226. 1 SIZE_1024X1536 = :"1024x1536"
  227. 1 SIZE_256X256 = :"256x256"
  228. 1 SIZE_512X512 = :"512x512"
  229. 1 SIZE_1792X1024 = :"1792x1024"
  230. 1 SIZE_1024X1792 = :"1024x1792"
  231. # @!method self.values
  232. # @return [Array<Symbol>]
  233. end
  234. # The style of the generated images. This parameter is only supported for
  235. # `dall-e-3`. Must be one of `vivid` or `natural`. Vivid causes the model to lean
  236. # towards generating hyper-real and dramatic images. Natural causes the model to
  237. # produce more natural, less hyper-real looking images.
  238. 1 module Style
  239. 1 extend OpenAI::Internal::Type::Enum
  240. 1 VIVID = :vivid
  241. 1 NATURAL = :natural
  242. # @!method self.values
  243. # @return [Array<Symbol>]
  244. end
  245. end
  246. end
  247. end

openai-ruby/lib/openai/models/image_model.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module ImageModel
  5. 1 extend OpenAI::Internal::Type::Enum
  6. 1 DALL_E_2 = :"dall-e-2"
  7. 1 DALL_E_3 = :"dall-e-3"
  8. 1 GPT_IMAGE_1 = :"gpt-image-1"
  9. # @!method self.values
  10. # @return [Array<Symbol>]
  11. end
  12. end
  13. end

openai-ruby/lib/openai/models/images_response.rb

100.0% lines covered

100.0% branches covered

37 relevant lines. 37 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Images#create_variation
  5. 1 class ImagesResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute created
  7. # The Unix timestamp (in seconds) of when the image was created.
  8. #
  9. # @return [Integer]
  10. 1 required :created, Integer
  11. # @!attribute background
  12. # The background parameter used for the image generation. Either `transparent` or
  13. # `opaque`.
  14. #
  15. # @return [Symbol, OpenAI::Models::ImagesResponse::Background, nil]
  16. 1 optional :background, enum: -> { OpenAI::ImagesResponse::Background }
  17. # @!attribute data
  18. # The list of generated images.
  19. #
  20. # @return [Array<OpenAI::Models::Image>, nil]
  21. 1 optional :data, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Image] }
  22. # @!attribute output_format
  23. # The output format of the image generation. Either `png`, `webp`, or `jpeg`.
  24. #
  25. # @return [Symbol, OpenAI::Models::ImagesResponse::OutputFormat, nil]
  26. 1 optional :output_format, enum: -> { OpenAI::ImagesResponse::OutputFormat }
  27. # @!attribute quality
  28. # The quality of the image generated. Either `low`, `medium`, or `high`.
  29. #
  30. # @return [Symbol, OpenAI::Models::ImagesResponse::Quality, nil]
  31. 1 optional :quality, enum: -> { OpenAI::ImagesResponse::Quality }
  32. # @!attribute size
  33. # The size of the image generated. Either `1024x1024`, `1024x1536`, or
  34. # `1536x1024`.
  35. #
  36. # @return [Symbol, OpenAI::Models::ImagesResponse::Size, nil]
  37. 1 optional :size, enum: -> { OpenAI::ImagesResponse::Size }
  38. # @!attribute usage
  39. # For `gpt-image-1` only, the token usage information for the image generation.
  40. #
  41. # @return [OpenAI::Models::ImagesResponse::Usage, nil]
  42. 1 optional :usage, -> { OpenAI::ImagesResponse::Usage }
  43. # @!method initialize(created:, background: nil, data: nil, output_format: nil, quality: nil, size: nil, usage: nil)
  44. # Some parameter documentations has been truncated, see
  45. # {OpenAI::Models::ImagesResponse} for more details.
  46. #
  47. # The response from the image generation endpoint.
  48. #
  49. # @param created [Integer] The Unix timestamp (in seconds) of when the image was created.
  50. #
  51. # @param background [Symbol, OpenAI::Models::ImagesResponse::Background] The background parameter used for the image generation. Either `transparent` or
  52. #
  53. # @param data [Array<OpenAI::Models::Image>] The list of generated images.
  54. #
  55. # @param output_format [Symbol, OpenAI::Models::ImagesResponse::OutputFormat] The output format of the image generation. Either `png`, `webp`, or `jpeg`.
  56. #
  57. # @param quality [Symbol, OpenAI::Models::ImagesResponse::Quality] The quality of the image generated. Either `low`, `medium`, or `high`.
  58. #
  59. # @param size [Symbol, OpenAI::Models::ImagesResponse::Size] The size of the image generated. Either `1024x1024`, `1024x1536`, or `1536x1024`
  60. #
  61. # @param usage [OpenAI::Models::ImagesResponse::Usage] For `gpt-image-1` only, the token usage information for the image generation.
  62. # The background parameter used for the image generation. Either `transparent` or
  63. # `opaque`.
  64. #
  65. # @see OpenAI::Models::ImagesResponse#background
  66. 1 module Background
  67. 1 extend OpenAI::Internal::Type::Enum
  68. 1 TRANSPARENT = :transparent
  69. 1 OPAQUE = :opaque
  70. # @!method self.values
  71. # @return [Array<Symbol>]
  72. end
  73. # The output format of the image generation. Either `png`, `webp`, or `jpeg`.
  74. #
  75. # @see OpenAI::Models::ImagesResponse#output_format
  76. 1 module OutputFormat
  77. 1 extend OpenAI::Internal::Type::Enum
  78. 1 PNG = :png
  79. 1 WEBP = :webp
  80. 1 JPEG = :jpeg
  81. # @!method self.values
  82. # @return [Array<Symbol>]
  83. end
  84. # The quality of the image generated. Either `low`, `medium`, or `high`.
  85. #
  86. # @see OpenAI::Models::ImagesResponse#quality
  87. 1 module Quality
  88. 1 extend OpenAI::Internal::Type::Enum
  89. 1 LOW = :low
  90. 1 MEDIUM = :medium
  91. 1 HIGH = :high
  92. # @!method self.values
  93. # @return [Array<Symbol>]
  94. end
  95. # The size of the image generated. Either `1024x1024`, `1024x1536`, or
  96. # `1536x1024`.
  97. #
  98. # @see OpenAI::Models::ImagesResponse#size
  99. 1 module Size
  100. 1 extend OpenAI::Internal::Type::Enum
  101. 1 SIZE_1024X1024 = :"1024x1024"
  102. 1 SIZE_1024X1536 = :"1024x1536"
  103. 1 SIZE_1536X1024 = :"1536x1024"
  104. # @!method self.values
  105. # @return [Array<Symbol>]
  106. end
  107. # @see OpenAI::Models::ImagesResponse#usage
  108. 1 class Usage < OpenAI::Internal::Type::BaseModel
  109. # @!attribute input_tokens
  110. # The number of tokens (images and text) in the input prompt.
  111. #
  112. # @return [Integer]
  113. 1 required :input_tokens, Integer
  114. # @!attribute input_tokens_details
  115. # The input tokens detailed information for the image generation.
  116. #
  117. # @return [OpenAI::Models::ImagesResponse::Usage::InputTokensDetails]
  118. 1 required :input_tokens_details, -> { OpenAI::ImagesResponse::Usage::InputTokensDetails }
  119. # @!attribute output_tokens
  120. # The number of output tokens generated by the model.
  121. #
  122. # @return [Integer]
  123. 1 required :output_tokens, Integer
  124. # @!attribute total_tokens
  125. # The total number of tokens (images and text) used for the image generation.
  126. #
  127. # @return [Integer]
  128. 1 required :total_tokens, Integer
  129. # @!method initialize(input_tokens:, input_tokens_details:, output_tokens:, total_tokens:)
  130. # For `gpt-image-1` only, the token usage information for the image generation.
  131. #
  132. # @param input_tokens [Integer] The number of tokens (images and text) in the input prompt.
  133. #
  134. # @param input_tokens_details [OpenAI::Models::ImagesResponse::Usage::InputTokensDetails] The input tokens detailed information for the image generation.
  135. #
  136. # @param output_tokens [Integer] The number of output tokens generated by the model.
  137. #
  138. # @param total_tokens [Integer] The total number of tokens (images and text) used for the image generation.
  139. # @see OpenAI::Models::ImagesResponse::Usage#input_tokens_details
  140. 1 class InputTokensDetails < OpenAI::Internal::Type::BaseModel
  141. # @!attribute image_tokens
  142. # The number of image tokens in the input prompt.
  143. #
  144. # @return [Integer]
  145. 1 required :image_tokens, Integer
  146. # @!attribute text_tokens
  147. # The number of text tokens in the input prompt.
  148. #
  149. # @return [Integer]
  150. 1 required :text_tokens, Integer
  151. # @!method initialize(image_tokens:, text_tokens:)
  152. # The input tokens detailed information for the image generation.
  153. #
  154. # @param image_tokens [Integer] The number of image tokens in the input prompt.
  155. #
  156. # @param text_tokens [Integer] The number of text tokens in the input prompt.
  157. end
  158. end
  159. end
  160. end
  161. end

openai-ruby/lib/openai/models/metadata.rb

100.0% lines covered

100.0% branches covered

3 relevant lines. 3 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @type [OpenAI::Internal::Type::Converter]
  5. 1 Metadata = OpenAI::Internal::Type::HashOf[String]
  6. end
  7. end

openai-ruby/lib/openai/models/model.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Models#retrieve
  5. 1 class Model < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The model identifier, which can be referenced in the API endpoints.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created
  12. # The Unix timestamp (in seconds) when the model was created.
  13. #
  14. # @return [Integer]
  15. 1 required :created, Integer
  16. # @!attribute object
  17. # The object type, which is always "model".
  18. #
  19. # @return [Symbol, :model]
  20. 1 required :object, const: :model
  21. # @!attribute owned_by
  22. # The organization that owns the model.
  23. #
  24. # @return [String]
  25. 1 required :owned_by, String
  26. # @!method initialize(id:, created:, owned_by:, object: :model)
  27. # Describes an OpenAI model offering that can be used with the API.
  28. #
  29. # @param id [String] The model identifier, which can be referenced in the API endpoints.
  30. #
  31. # @param created [Integer] The Unix timestamp (in seconds) when the model was created.
  32. #
  33. # @param owned_by [String] The organization that owns the model.
  34. #
  35. # @param object [Symbol, :model] The object type, which is always "model".
  36. end
  37. end
  38. end

openai-ruby/lib/openai/models/model_delete_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Models#delete
  5. 1 class ModelDeleteParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/model_deleted.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Models#delete
  5. 1 class ModelDeleted < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. #
  8. # @return [String]
  9. 1 required :id, String
  10. # @!attribute deleted
  11. #
  12. # @return [Boolean]
  13. 1 required :deleted, OpenAI::Internal::Type::Boolean
  14. # @!attribute object
  15. #
  16. # @return [String]
  17. 1 required :object, String
  18. # @!method initialize(id:, deleted:, object:)
  19. # @param id [String]
  20. # @param deleted [Boolean]
  21. # @param object [String]
  22. end
  23. end
  24. end

openai-ruby/lib/openai/models/model_list_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Models#list
  5. 1 class ModelListParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/model_retrieve_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Models#retrieve
  5. 1 class ModelRetrieveParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/moderation.rb

87.85% lines covered

100.0% branches covered

107 relevant lines. 94 lines covered and 13 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class Moderation < OpenAI::Internal::Type::BaseModel
  5. # @!attribute categories
  6. # A list of the categories, and whether they are flagged or not.
  7. #
  8. # @return [OpenAI::Models::Moderation::Categories]
  9. 1 required :categories, -> { OpenAI::Moderation::Categories }
  10. # @!attribute category_applied_input_types
  11. # A list of the categories along with the input type(s) that the score applies to.
  12. #
  13. # @return [OpenAI::Models::Moderation::CategoryAppliedInputTypes]
  14. 1 required :category_applied_input_types, -> { OpenAI::Moderation::CategoryAppliedInputTypes }
  15. # @!attribute category_scores
  16. # A list of the categories along with their scores as predicted by model.
  17. #
  18. # @return [OpenAI::Models::Moderation::CategoryScores]
  19. 1 required :category_scores, -> { OpenAI::Moderation::CategoryScores }
  20. # @!attribute flagged
  21. # Whether any of the below categories are flagged.
  22. #
  23. # @return [Boolean]
  24. 1 required :flagged, OpenAI::Internal::Type::Boolean
  25. # @!method initialize(categories:, category_applied_input_types:, category_scores:, flagged:)
  26. # Some parameter documentations has been truncated, see
  27. # {OpenAI::Models::Moderation} for more details.
  28. #
  29. # @param categories [OpenAI::Models::Moderation::Categories] A list of the categories, and whether they are flagged or not.
  30. #
  31. # @param category_applied_input_types [OpenAI::Models::Moderation::CategoryAppliedInputTypes] A list of the categories along with the input type(s) that the score applies to.
  32. #
  33. # @param category_scores [OpenAI::Models::Moderation::CategoryScores] A list of the categories along with their scores as predicted by model.
  34. #
  35. # @param flagged [Boolean] Whether any of the below categories are flagged.
  36. # @see OpenAI::Models::Moderation#categories
  37. 1 class Categories < OpenAI::Internal::Type::BaseModel
  38. # @!attribute harassment
  39. # Content that expresses, incites, or promotes harassing language towards any
  40. # target.
  41. #
  42. # @return [Boolean]
  43. 1 required :harassment, OpenAI::Internal::Type::Boolean
  44. # @!attribute harassment_threatening
  45. # Harassment content that also includes violence or serious harm towards any
  46. # target.
  47. #
  48. # @return [Boolean]
  49. 1 required :harassment_threatening, OpenAI::Internal::Type::Boolean, api_name: :"harassment/threatening"
  50. # @!attribute hate
  51. # Content that expresses, incites, or promotes hate based on race, gender,
  52. # ethnicity, religion, nationality, sexual orientation, disability status, or
  53. # caste. Hateful content aimed at non-protected groups (e.g., chess players) is
  54. # harassment.
  55. #
  56. # @return [Boolean]
  57. 1 required :hate, OpenAI::Internal::Type::Boolean
  58. # @!attribute hate_threatening
  59. # Hateful content that also includes violence or serious harm towards the targeted
  60. # group based on race, gender, ethnicity, religion, nationality, sexual
  61. # orientation, disability status, or caste.
  62. #
  63. # @return [Boolean]
  64. 1 required :hate_threatening, OpenAI::Internal::Type::Boolean, api_name: :"hate/threatening"
  65. # @!attribute illicit
  66. # Content that includes instructions or advice that facilitate the planning or
  67. # execution of wrongdoing, or that gives advice or instruction on how to commit
  68. # illicit acts. For example, "how to shoplift" would fit this category.
  69. #
  70. # @return [Boolean, nil]
  71. 1 required :illicit, OpenAI::Internal::Type::Boolean, nil?: true
  72. # @!attribute illicit_violent
  73. # Content that includes instructions or advice that facilitate the planning or
  74. # execution of wrongdoing that also includes violence, or that gives advice or
  75. # instruction on the procurement of any weapon.
  76. #
  77. # @return [Boolean, nil]
  78. 1 required :illicit_violent, OpenAI::Internal::Type::Boolean, api_name: :"illicit/violent", nil?: true
  79. # @!attribute self_harm
  80. # Content that promotes, encourages, or depicts acts of self-harm, such as
  81. # suicide, cutting, and eating disorders.
  82. #
  83. # @return [Boolean]
  84. 1 required :self_harm, OpenAI::Internal::Type::Boolean, api_name: :"self-harm"
  85. # @!attribute self_harm_instructions
  86. # Content that encourages performing acts of self-harm, such as suicide, cutting,
  87. # and eating disorders, or that gives instructions or advice on how to commit such
  88. # acts.
  89. #
  90. # @return [Boolean]
  91. 1 required :self_harm_instructions, OpenAI::Internal::Type::Boolean, api_name: :"self-harm/instructions"
  92. # @!attribute self_harm_intent
  93. # Content where the speaker expresses that they are engaging or intend to engage
  94. # in acts of self-harm, such as suicide, cutting, and eating disorders.
  95. #
  96. # @return [Boolean]
  97. 1 required :self_harm_intent, OpenAI::Internal::Type::Boolean, api_name: :"self-harm/intent"
  98. # @!attribute sexual
  99. # Content meant to arouse sexual excitement, such as the description of sexual
  100. # activity, or that promotes sexual services (excluding sex education and
  101. # wellness).
  102. #
  103. # @return [Boolean]
  104. 1 required :sexual, OpenAI::Internal::Type::Boolean
  105. # @!attribute sexual_minors
  106. # Sexual content that includes an individual who is under 18 years old.
  107. #
  108. # @return [Boolean]
  109. 1 required :sexual_minors, OpenAI::Internal::Type::Boolean, api_name: :"sexual/minors"
  110. # @!attribute violence
  111. # Content that depicts death, violence, or physical injury.
  112. #
  113. # @return [Boolean]
  114. 1 required :violence, OpenAI::Internal::Type::Boolean
  115. # @!attribute violence_graphic
  116. # Content that depicts death, violence, or physical injury in graphic detail.
  117. #
  118. # @return [Boolean]
  119. 1 required :violence_graphic, OpenAI::Internal::Type::Boolean, api_name: :"violence/graphic"
  120. # @!method initialize(harassment:, harassment_threatening:, hate:, hate_threatening:, illicit:, illicit_violent:, self_harm:, self_harm_instructions:, self_harm_intent:, sexual:, sexual_minors:, violence:, violence_graphic:)
  121. # Some parameter documentations has been truncated, see
  122. # {OpenAI::Models::Moderation::Categories} for more details.
  123. #
  124. # A list of the categories, and whether they are flagged or not.
  125. #
  126. # @param harassment [Boolean] Content that expresses, incites, or promotes harassing language towards any targ
  127. #
  128. # @param harassment_threatening [Boolean] Harassment content that also includes violence or serious harm towards any targe
  129. #
  130. # @param hate [Boolean] Content that expresses, incites, or promotes hate based on race, gender, ethnici
  131. #
  132. # @param hate_threatening [Boolean] Hateful content that also includes violence or serious harm towards the targeted
  133. #
  134. # @param illicit [Boolean, nil] Content that includes instructions or advice that facilitate the planning or exe
  135. #
  136. # @param illicit_violent [Boolean, nil] Content that includes instructions or advice that facilitate the planning or exe
  137. #
  138. # @param self_harm [Boolean] Content that promotes, encourages, or depicts acts of self-harm, such as suicide
  139. #
  140. # @param self_harm_instructions [Boolean] Content that encourages performing acts of self-harm, such as suicide, cutting,
  141. #
  142. # @param self_harm_intent [Boolean] Content where the speaker expresses that they are engaging or intend to engage i
  143. #
  144. # @param sexual [Boolean] Content meant to arouse sexual excitement, such as the description of sexual act
  145. #
  146. # @param sexual_minors [Boolean] Sexual content that includes an individual who is under 18 years old.
  147. #
  148. # @param violence [Boolean] Content that depicts death, violence, or physical injury.
  149. #
  150. # @param violence_graphic [Boolean] Content that depicts death, violence, or physical injury in graphic detail.
  151. end
  152. # @see OpenAI::Models::Moderation#category_applied_input_types
  153. 1 class CategoryAppliedInputTypes < OpenAI::Internal::Type::BaseModel
  154. # @!attribute harassment
  155. # The applied input type(s) for the category 'harassment'.
  156. #
  157. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Harassment>]
  158. 1 required :harassment,
  159. -> {
  160. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::Harassment]
  161. }
  162. # @!attribute harassment_threatening
  163. # The applied input type(s) for the category 'harassment/threatening'.
  164. #
  165. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HarassmentThreatening>]
  166. 1 required :harassment_threatening,
  167. -> {
  168. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::HarassmentThreatening]
  169. },
  170. api_name: :"harassment/threatening"
  171. # @!attribute hate
  172. # The applied input type(s) for the category 'hate'.
  173. #
  174. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Hate>]
  175. 1 required :hate,
  176. -> {
  177. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::Hate]
  178. }
  179. # @!attribute hate_threatening
  180. # The applied input type(s) for the category 'hate/threatening'.
  181. #
  182. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HateThreatening>]
  183. 1 required :hate_threatening,
  184. -> {
  185. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::HateThreatening]
  186. },
  187. api_name: :"hate/threatening"
  188. # @!attribute illicit
  189. # The applied input type(s) for the category 'illicit'.
  190. #
  191. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Illicit>]
  192. 1 required :illicit,
  193. -> {
  194. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::Illicit]
  195. }
  196. # @!attribute illicit_violent
  197. # The applied input type(s) for the category 'illicit/violent'.
  198. #
  199. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::IllicitViolent>]
  200. 1 required :illicit_violent,
  201. -> {
  202. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::IllicitViolent]
  203. },
  204. api_name: :"illicit/violent"
  205. # @!attribute self_harm
  206. # The applied input type(s) for the category 'self-harm'.
  207. #
  208. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm>]
  209. 1 required :self_harm,
  210. -> {
  211. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::SelfHarm]
  212. },
  213. api_name: :"self-harm"
  214. # @!attribute self_harm_instructions
  215. # The applied input type(s) for the category 'self-harm/instructions'.
  216. #
  217. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction>]
  218. 1 required :self_harm_instructions,
  219. -> {
  220. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction]
  221. },
  222. api_name: :"self-harm/instructions"
  223. # @!attribute self_harm_intent
  224. # The applied input type(s) for the category 'self-harm/intent'.
  225. #
  226. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent>]
  227. 1 required :self_harm_intent,
  228. -> {
  229. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::SelfHarmIntent]
  230. },
  231. api_name: :"self-harm/intent"
  232. # @!attribute sexual
  233. # The applied input type(s) for the category 'sexual'.
  234. #
  235. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual>]
  236. 1 required :sexual,
  237. -> {
  238. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::Sexual]
  239. }
  240. # @!attribute sexual_minors
  241. # The applied input type(s) for the category 'sexual/minors'.
  242. #
  243. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SexualMinor>]
  244. 1 required :sexual_minors,
  245. -> {
  246. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::SexualMinor]
  247. },
  248. api_name: :"sexual/minors"
  249. # @!attribute violence
  250. # The applied input type(s) for the category 'violence'.
  251. #
  252. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence>]
  253. 1 required :violence,
  254. -> {
  255. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::Violence]
  256. }
  257. # @!attribute violence_graphic
  258. # The applied input type(s) for the category 'violence/graphic'.
  259. #
  260. # @return [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic>]
  261. 1 required :violence_graphic,
  262. -> {
  263. OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Moderation::CategoryAppliedInputTypes::ViolenceGraphic]
  264. },
  265. api_name: :"violence/graphic"
  266. # @!method initialize(harassment:, harassment_threatening:, hate:, hate_threatening:, illicit:, illicit_violent:, self_harm:, self_harm_instructions:, self_harm_intent:, sexual:, sexual_minors:, violence:, violence_graphic:)
  267. # A list of the categories along with the input type(s) that the score applies to.
  268. #
  269. # @param harassment [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Harassment>] The applied input type(s) for the category 'harassment'.
  270. #
  271. # @param harassment_threatening [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HarassmentThreatening>] The applied input type(s) for the category 'harassment/threatening'.
  272. #
  273. # @param hate [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Hate>] The applied input type(s) for the category 'hate'.
  274. #
  275. # @param hate_threatening [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::HateThreatening>] The applied input type(s) for the category 'hate/threatening'.
  276. #
  277. # @param illicit [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Illicit>] The applied input type(s) for the category 'illicit'.
  278. #
  279. # @param illicit_violent [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::IllicitViolent>] The applied input type(s) for the category 'illicit/violent'.
  280. #
  281. # @param self_harm [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarm>] The applied input type(s) for the category 'self-harm'.
  282. #
  283. # @param self_harm_instructions [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmInstruction>] The applied input type(s) for the category 'self-harm/instructions'.
  284. #
  285. # @param self_harm_intent [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SelfHarmIntent>] The applied input type(s) for the category 'self-harm/intent'.
  286. #
  287. # @param sexual [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Sexual>] The applied input type(s) for the category 'sexual'.
  288. #
  289. # @param sexual_minors [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::SexualMinor>] The applied input type(s) for the category 'sexual/minors'.
  290. #
  291. # @param violence [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::Violence>] The applied input type(s) for the category 'violence'.
  292. #
  293. # @param violence_graphic [Array<Symbol, OpenAI::Models::Moderation::CategoryAppliedInputTypes::ViolenceGraphic>] The applied input type(s) for the category 'violence/graphic'.
  294. 1 module Harassment
  295. 1 extend OpenAI::Internal::Type::Enum
  296. 1 TEXT = :text
  297. # @!method self.values
  298. # @return [Array<Symbol>]
  299. end
  300. 1 module HarassmentThreatening
  301. 1 extend OpenAI::Internal::Type::Enum
  302. 1 TEXT = :text
  303. # @!method self.values
  304. # @return [Array<Symbol>]
  305. end
  306. 1 module Hate
  307. 1 extend OpenAI::Internal::Type::Enum
  308. 1 TEXT = :text
  309. # @!method self.values
  310. # @return [Array<Symbol>]
  311. end
  312. 1 module HateThreatening
  313. 1 extend OpenAI::Internal::Type::Enum
  314. 1 TEXT = :text
  315. # @!method self.values
  316. # @return [Array<Symbol>]
  317. end
  318. 1 module Illicit
  319. 1 extend OpenAI::Internal::Type::Enum
  320. 1 TEXT = :text
  321. # @!method self.values
  322. # @return [Array<Symbol>]
  323. end
  324. 1 module IllicitViolent
  325. 1 extend OpenAI::Internal::Type::Enum
  326. 1 TEXT = :text
  327. # @!method self.values
  328. # @return [Array<Symbol>]
  329. end
  330. 1 module SelfHarm
  331. 1 extend OpenAI::Internal::Type::Enum
  332. 1 TEXT = :text
  333. 1 IMAGE = :image
  334. # @!method self.values
  335. # @return [Array<Symbol>]
  336. end
  337. 1 module SelfHarmInstruction
  338. 1 extend OpenAI::Internal::Type::Enum
  339. 1 TEXT = :text
  340. 1 IMAGE = :image
  341. # @!method self.values
  342. # @return [Array<Symbol>]
  343. end
  344. 1 module SelfHarmIntent
  345. 1 extend OpenAI::Internal::Type::Enum
  346. 1 TEXT = :text
  347. 1 IMAGE = :image
  348. # @!method self.values
  349. # @return [Array<Symbol>]
  350. end
  351. 1 module Sexual
  352. 1 extend OpenAI::Internal::Type::Enum
  353. 1 TEXT = :text
  354. 1 IMAGE = :image
  355. # @!method self.values
  356. # @return [Array<Symbol>]
  357. end
  358. 1 module SexualMinor
  359. 1 extend OpenAI::Internal::Type::Enum
  360. 1 TEXT = :text
  361. # @!method self.values
  362. # @return [Array<Symbol>]
  363. end
  364. 1 module Violence
  365. 1 extend OpenAI::Internal::Type::Enum
  366. 1 TEXT = :text
  367. 1 IMAGE = :image
  368. # @!method self.values
  369. # @return [Array<Symbol>]
  370. end
  371. 1 module ViolenceGraphic
  372. 1 extend OpenAI::Internal::Type::Enum
  373. 1 TEXT = :text
  374. 1 IMAGE = :image
  375. # @!method self.values
  376. # @return [Array<Symbol>]
  377. end
  378. end
  379. # @see OpenAI::Models::Moderation#category_scores
  380. 1 class CategoryScores < OpenAI::Internal::Type::BaseModel
  381. # @!attribute harassment
  382. # The score for the category 'harassment'.
  383. #
  384. # @return [Float]
  385. 1 required :harassment, Float
  386. # @!attribute harassment_threatening
  387. # The score for the category 'harassment/threatening'.
  388. #
  389. # @return [Float]
  390. 1 required :harassment_threatening, Float, api_name: :"harassment/threatening"
  391. # @!attribute hate
  392. # The score for the category 'hate'.
  393. #
  394. # @return [Float]
  395. 1 required :hate, Float
  396. # @!attribute hate_threatening
  397. # The score for the category 'hate/threatening'.
  398. #
  399. # @return [Float]
  400. 1 required :hate_threatening, Float, api_name: :"hate/threatening"
  401. # @!attribute illicit
  402. # The score for the category 'illicit'.
  403. #
  404. # @return [Float]
  405. 1 required :illicit, Float
  406. # @!attribute illicit_violent
  407. # The score for the category 'illicit/violent'.
  408. #
  409. # @return [Float]
  410. 1 required :illicit_violent, Float, api_name: :"illicit/violent"
  411. # @!attribute self_harm
  412. # The score for the category 'self-harm'.
  413. #
  414. # @return [Float]
  415. 1 required :self_harm, Float, api_name: :"self-harm"
  416. # @!attribute self_harm_instructions
  417. # The score for the category 'self-harm/instructions'.
  418. #
  419. # @return [Float]
  420. 1 required :self_harm_instructions, Float, api_name: :"self-harm/instructions"
  421. # @!attribute self_harm_intent
  422. # The score for the category 'self-harm/intent'.
  423. #
  424. # @return [Float]
  425. 1 required :self_harm_intent, Float, api_name: :"self-harm/intent"
  426. # @!attribute sexual
  427. # The score for the category 'sexual'.
  428. #
  429. # @return [Float]
  430. 1 required :sexual, Float
  431. # @!attribute sexual_minors
  432. # The score for the category 'sexual/minors'.
  433. #
  434. # @return [Float]
  435. 1 required :sexual_minors, Float, api_name: :"sexual/minors"
  436. # @!attribute violence
  437. # The score for the category 'violence'.
  438. #
  439. # @return [Float]
  440. 1 required :violence, Float
  441. # @!attribute violence_graphic
  442. # The score for the category 'violence/graphic'.
  443. #
  444. # @return [Float]
  445. 1 required :violence_graphic, Float, api_name: :"violence/graphic"
  446. # @!method initialize(harassment:, harassment_threatening:, hate:, hate_threatening:, illicit:, illicit_violent:, self_harm:, self_harm_instructions:, self_harm_intent:, sexual:, sexual_minors:, violence:, violence_graphic:)
  447. # A list of the categories along with their scores as predicted by model.
  448. #
  449. # @param harassment [Float] The score for the category 'harassment'.
  450. #
  451. # @param harassment_threatening [Float] The score for the category 'harassment/threatening'.
  452. #
  453. # @param hate [Float] The score for the category 'hate'.
  454. #
  455. # @param hate_threatening [Float] The score for the category 'hate/threatening'.
  456. #
  457. # @param illicit [Float] The score for the category 'illicit'.
  458. #
  459. # @param illicit_violent [Float] The score for the category 'illicit/violent'.
  460. #
  461. # @param self_harm [Float] The score for the category 'self-harm'.
  462. #
  463. # @param self_harm_instructions [Float] The score for the category 'self-harm/instructions'.
  464. #
  465. # @param self_harm_intent [Float] The score for the category 'self-harm/intent'.
  466. #
  467. # @param sexual [Float] The score for the category 'sexual'.
  468. #
  469. # @param sexual_minors [Float] The score for the category 'sexual/minors'.
  470. #
  471. # @param violence [Float] The score for the category 'violence'.
  472. #
  473. # @param violence_graphic [Float] The score for the category 'violence/graphic'.
  474. end
  475. end
  476. end
  477. end

openai-ruby/lib/openai/models/moderation_create_params.rb

100.0% lines covered

100.0% branches covered

18 relevant lines. 18 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Moderations#create
  5. 1 class ModerationCreateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute input
  9. # Input (or inputs) to classify. Can be a single string, an array of strings, or
  10. # an array of multi-modal input objects similar to other models.
  11. #
  12. # @return [String, Array<String>, Array<OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput>]
  13. 1 required :input, union: -> { OpenAI::ModerationCreateParams::Input }
  14. # @!attribute model
  15. # The content moderation model you would like to use. Learn more in
  16. # [the moderation guide](https://platform.openai.com/docs/guides/moderation), and
  17. # learn about available models
  18. # [here](https://platform.openai.com/docs/models#moderation).
  19. #
  20. # @return [String, Symbol, OpenAI::Models::ModerationModel, nil]
  21. 1 optional :model, union: -> { OpenAI::ModerationCreateParams::Model }
  22. # @!method initialize(input:, model: nil, request_options: {})
  23. # Some parameter documentations has been truncated, see
  24. # {OpenAI::Models::ModerationCreateParams} for more details.
  25. #
  26. # @param input [String, Array<String>, Array<OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput>] Input (or inputs) to classify. Can be a single string, an array of strings, or
  27. #
  28. # @param model [String, Symbol, OpenAI::Models::ModerationModel] The content moderation model you would like to use. Learn more in
  29. #
  30. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  31. # Input (or inputs) to classify. Can be a single string, an array of strings, or
  32. # an array of multi-modal input objects similar to other models.
  33. 1 module Input
  34. 1 extend OpenAI::Internal::Type::Union
  35. # A string of text to classify for moderation.
  36. 1 variant String
  37. # An array of strings to classify for moderation.
  38. 1 variant -> { OpenAI::Models::ModerationCreateParams::Input::StringArray }
  39. # An array of multi-modal inputs to the moderation model.
  40. 1 variant -> { OpenAI::Models::ModerationCreateParams::Input::ModerationMultiModalInputArray }
  41. # @!method self.variants
  42. # @return [Array(String, Array<String>, Array<OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput>)]
  43. # @type [OpenAI::Internal::Type::Converter]
  44. 1 StringArray = OpenAI::Internal::Type::ArrayOf[String]
  45. # @type [OpenAI::Internal::Type::Converter]
  46. ModerationMultiModalInputArray =
  47. 1 OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::ModerationMultiModalInput }]
  48. end
  49. # The content moderation model you would like to use. Learn more in
  50. # [the moderation guide](https://platform.openai.com/docs/guides/moderation), and
  51. # learn about available models
  52. # [here](https://platform.openai.com/docs/models#moderation).
  53. 1 module Model
  54. 1 extend OpenAI::Internal::Type::Union
  55. 1 variant String
  56. # The content moderation model you would like to use. Learn more in
  57. # [the moderation guide](https://platform.openai.com/docs/guides/moderation), and learn about
  58. # available models [here](https://platform.openai.com/docs/models#moderation).
  59. 1 variant enum: -> { OpenAI::ModerationModel }
  60. # @!method self.variants
  61. # @return [Array(String, Symbol, OpenAI::Models::ModerationModel)]
  62. end
  63. end
  64. end
  65. end

openai-ruby/lib/openai/models/moderation_create_response.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Moderations#create
  5. 1 class ModerationCreateResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique identifier for the moderation request.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute model
  12. # The model used to generate the moderation results.
  13. #
  14. # @return [String]
  15. 1 required :model, String
  16. # @!attribute results
  17. # A list of moderation objects.
  18. #
  19. # @return [Array<OpenAI::Models::Moderation>]
  20. 1 required :results, -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Moderation] }
  21. # @!method initialize(id:, model:, results:)
  22. # Represents if a given text input is potentially harmful.
  23. #
  24. # @param id [String] The unique identifier for the moderation request.
  25. #
  26. # @param model [String] The model used to generate the moderation results.
  27. #
  28. # @param results [Array<OpenAI::Models::Moderation>] A list of moderation objects.
  29. end
  30. end
  31. end

openai-ruby/lib/openai/models/moderation_image_url_input.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ModerationImageURLInput < OpenAI::Internal::Type::BaseModel
  5. # @!attribute image_url
  6. # Contains either an image URL or a data URL for a base64 encoded image.
  7. #
  8. # @return [OpenAI::Models::ModerationImageURLInput::ImageURL]
  9. 1 required :image_url, -> { OpenAI::ModerationImageURLInput::ImageURL }
  10. # @!attribute type
  11. # Always `image_url`.
  12. #
  13. # @return [Symbol, :image_url]
  14. 1 required :type, const: :image_url
  15. # @!method initialize(image_url:, type: :image_url)
  16. # An object describing an image to classify.
  17. #
  18. # @param image_url [OpenAI::Models::ModerationImageURLInput::ImageURL] Contains either an image URL or a data URL for a base64 encoded image.
  19. #
  20. # @param type [Symbol, :image_url] Always `image_url`.
  21. # @see OpenAI::Models::ModerationImageURLInput#image_url
  22. 1 class ImageURL < OpenAI::Internal::Type::BaseModel
  23. # @!attribute url
  24. # Either a URL of the image or the base64 encoded image data.
  25. #
  26. # @return [String]
  27. 1 required :url, String
  28. # @!method initialize(url:)
  29. # Contains either an image URL or a data URL for a base64 encoded image.
  30. #
  31. # @param url [String] Either a URL of the image or the base64 encoded image data.
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/moderation_model.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module ModerationModel
  5. 1 extend OpenAI::Internal::Type::Enum
  6. 1 OMNI_MODERATION_LATEST = :"omni-moderation-latest"
  7. 1 OMNI_MODERATION_2024_09_26 = :"omni-moderation-2024-09-26"
  8. 1 TEXT_MODERATION_LATEST = :"text-moderation-latest"
  9. 1 TEXT_MODERATION_STABLE = :"text-moderation-stable"
  10. # @!method self.values
  11. # @return [Array<Symbol>]
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/moderation_multi_modal_input.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # An object describing an image to classify.
  5. 1 module ModerationMultiModalInput
  6. 1 extend OpenAI::Internal::Type::Union
  7. 1 discriminator :type
  8. # An object describing an image to classify.
  9. 1 variant :image_url, -> { OpenAI::ModerationImageURLInput }
  10. # An object describing text to classify.
  11. 1 variant :text, -> { OpenAI::ModerationTextInput }
  12. # @!method self.variants
  13. # @return [Array(OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput)]
  14. end
  15. end
  16. end

openai-ruby/lib/openai/models/moderation_text_input.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ModerationTextInput < OpenAI::Internal::Type::BaseModel
  5. # @!attribute text
  6. # A string of text to classify.
  7. #
  8. # @return [String]
  9. 1 required :text, String
  10. # @!attribute type
  11. # Always `text`.
  12. #
  13. # @return [Symbol, :text]
  14. 1 required :type, const: :text
  15. # @!method initialize(text:, type: :text)
  16. # An object describing text to classify.
  17. #
  18. # @param text [String] A string of text to classify.
  19. #
  20. # @param type [Symbol, :text] Always `text`.
  21. end
  22. end
  23. end

openai-ruby/lib/openai/models/other_file_chunking_strategy_object.rb

100.0% lines covered

100.0% branches covered

4 relevant lines. 4 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class OtherFileChunkingStrategyObject < OpenAI::Internal::Type::BaseModel
  5. # @!attribute type
  6. # Always `other`.
  7. #
  8. # @return [Symbol, :other]
  9. 1 required :type, const: :other
  10. # @!method initialize(type: :other)
  11. # This is returned when the chunking strategy is unknown. Typically, this is
  12. # because the file was indexed before the `chunking_strategy` concept was
  13. # introduced in the API.
  14. #
  15. # @param type [Symbol, :other] Always `other`.
  16. end
  17. end
  18. end

openai-ruby/lib/openai/models/reasoning.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class Reasoning < OpenAI::Internal::Type::BaseModel
  5. # @!attribute effort
  6. # **o-series models only**
  7. #
  8. # Constrains effort on reasoning for
  9. # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
  10. # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
  11. # result in faster responses and fewer tokens used on reasoning in a response.
  12. #
  13. # @return [Symbol, OpenAI::Models::ReasoningEffort, nil]
  14. 1 optional :effort, enum: -> { OpenAI::ReasoningEffort }, nil?: true
  15. # @!attribute generate_summary
  16. # @deprecated
  17. #
  18. # **Deprecated:** use `summary` instead.
  19. #
  20. # A summary of the reasoning performed by the model. This can be useful for
  21. # debugging and understanding the model's reasoning process. One of `auto`,
  22. # `concise`, or `detailed`.
  23. #
  24. # @return [Symbol, OpenAI::Models::Reasoning::GenerateSummary, nil]
  25. 1 optional :generate_summary, enum: -> { OpenAI::Reasoning::GenerateSummary }, nil?: true
  26. # @!attribute summary
  27. # A summary of the reasoning performed by the model. This can be useful for
  28. # debugging and understanding the model's reasoning process. One of `auto`,
  29. # `concise`, or `detailed`.
  30. #
  31. # @return [Symbol, OpenAI::Models::Reasoning::Summary, nil]
  32. 1 optional :summary, enum: -> { OpenAI::Reasoning::Summary }, nil?: true
  33. # @!method initialize(effort: nil, generate_summary: nil, summary: nil)
  34. # Some parameter documentations has been truncated, see
  35. # {OpenAI::Models::Reasoning} for more details.
  36. #
  37. # **o-series models only**
  38. #
  39. # Configuration options for
  40. # [reasoning models](https://platform.openai.com/docs/guides/reasoning).
  41. #
  42. # @param effort [Symbol, OpenAI::Models::ReasoningEffort, nil] **o-series models only**
  43. #
  44. # @param generate_summary [Symbol, OpenAI::Models::Reasoning::GenerateSummary, nil] **Deprecated:** use `summary` instead.
  45. #
  46. # @param summary [Symbol, OpenAI::Models::Reasoning::Summary, nil] A summary of the reasoning performed by the model. This can be
  47. # @deprecated
  48. #
  49. # **Deprecated:** use `summary` instead.
  50. #
  51. # A summary of the reasoning performed by the model. This can be useful for
  52. # debugging and understanding the model's reasoning process. One of `auto`,
  53. # `concise`, or `detailed`.
  54. #
  55. # @see OpenAI::Models::Reasoning#generate_summary
  56. 1 module GenerateSummary
  57. 1 extend OpenAI::Internal::Type::Enum
  58. 1 AUTO = :auto
  59. 1 CONCISE = :concise
  60. 1 DETAILED = :detailed
  61. # @!method self.values
  62. # @return [Array<Symbol>]
  63. end
  64. # A summary of the reasoning performed by the model. This can be useful for
  65. # debugging and understanding the model's reasoning process. One of `auto`,
  66. # `concise`, or `detailed`.
  67. #
  68. # @see OpenAI::Models::Reasoning#summary
  69. 1 module Summary
  70. 1 extend OpenAI::Internal::Type::Enum
  71. 1 AUTO = :auto
  72. 1 CONCISE = :concise
  73. 1 DETAILED = :detailed
  74. # @!method self.values
  75. # @return [Array<Symbol>]
  76. end
  77. end
  78. end
  79. end

openai-ruby/lib/openai/models/reasoning_effort.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # **o-series models only**
  5. #
  6. # Constrains effort on reasoning for
  7. # [reasoning models](https://platform.openai.com/docs/guides/reasoning). Currently
  8. # supported values are `low`, `medium`, and `high`. Reducing reasoning effort can
  9. # result in faster responses and fewer tokens used on reasoning in a response.
  10. 1 module ReasoningEffort
  11. 1 extend OpenAI::Internal::Type::Enum
  12. 1 LOW = :low
  13. 1 MEDIUM = :medium
  14. 1 HIGH = :high
  15. # @!method self.values
  16. # @return [Array<Symbol>]
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/response_format_json_object.rb

100.0% lines covered

100.0% branches covered

4 relevant lines. 4 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ResponseFormatJSONObject < OpenAI::Internal::Type::BaseModel
  5. # @!attribute type
  6. # The type of response format being defined. Always `json_object`.
  7. #
  8. # @return [Symbol, :json_object]
  9. 1 required :type, const: :json_object
  10. # @!method initialize(type: :json_object)
  11. # JSON object response format. An older method of generating JSON responses. Using
  12. # `json_schema` is recommended for models that support it. Note that the model
  13. # will not generate JSON without a system or user message instructing it to do so.
  14. #
  15. # @param type [Symbol, :json_object] The type of response format being defined. Always `json_object`.
  16. end
  17. end
  18. end

openai-ruby/lib/openai/models/response_format_json_schema.rb

90.91% lines covered

100.0% branches covered

11 relevant lines. 10 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ResponseFormatJSONSchema < OpenAI::Internal::Type::BaseModel
  5. # @!attribute json_schema
  6. # Structured Outputs configuration options, including a JSON Schema.
  7. #
  8. # @return [OpenAI::Models::ResponseFormatJSONSchema::JSONSchema]
  9. 1 required :json_schema, -> { OpenAI::ResponseFormatJSONSchema::JSONSchema }
  10. # @!attribute type
  11. # The type of response format being defined. Always `json_schema`.
  12. #
  13. # @return [Symbol, :json_schema]
  14. 1 required :type, const: :json_schema
  15. # @!method initialize(json_schema:, type: :json_schema)
  16. # Some parameter documentations has been truncated, see
  17. # {OpenAI::Models::ResponseFormatJSONSchema} for more details.
  18. #
  19. # JSON Schema response format. Used to generate structured JSON responses. Learn
  20. # more about
  21. # [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
  22. #
  23. # @param json_schema [OpenAI::Models::ResponseFormatJSONSchema::JSONSchema] Structured Outputs configuration options, including a JSON Schema.
  24. #
  25. # @param type [Symbol, :json_schema] The type of response format being defined. Always `json_schema`.
  26. # @see OpenAI::Models::ResponseFormatJSONSchema#json_schema
  27. 1 class JSONSchema < OpenAI::Internal::Type::BaseModel
  28. # @!attribute name
  29. # The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
  30. # and dashes, with a maximum length of 64.
  31. #
  32. # @return [String]
  33. 1 required :name, String
  34. # @!attribute description
  35. # A description of what the response format is for, used by the model to determine
  36. # how to respond in the format.
  37. #
  38. # @return [String, nil]
  39. 1 optional :description, String
  40. # @!attribute schema
  41. # The schema for the response format, described as a JSON Schema object. Learn how
  42. # to build JSON schemas [here](https://json-schema.org/).
  43. #
  44. # @return [Hash{Symbol=>Object}, nil]
  45. 1 optional :schema,
  46. union: -> {
  47. OpenAI::UnionOf[
  48. OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown],
  49. OpenAI::StructuredOutput::JsonSchemaConverter
  50. ]
  51. }
  52. # @!attribute strict
  53. # Whether to enable strict schema adherence when generating the output. If set to
  54. # true, the model will always follow the exact schema defined in the `schema`
  55. # field. Only a subset of JSON Schema is supported when `strict` is `true`. To
  56. # learn more, read the
  57. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  58. #
  59. # @return [Boolean, nil]
  60. 1 optional :strict, OpenAI::Internal::Type::Boolean, nil?: true
  61. # @!method initialize(name:, description: nil, schema: nil, strict: nil)
  62. # Some parameter documentations has been truncated, see
  63. # {OpenAI::Models::ResponseFormatJSONSchema::JSONSchema} for more details.
  64. #
  65. # Structured Outputs configuration options, including a JSON Schema.
  66. #
  67. # @param name [String] The name of the response format. Must be a-z, A-Z, 0-9, or contain
  68. #
  69. # @param description [String] A description of what the response format is for, used by the model to
  70. #
  71. # @param schema [Hash{Symbol=>Object}, OpenAI::StructuredOutput::JsonSchemaConverter] The schema for the response format, described as a JSON Schema object.
  72. #
  73. # @param strict [Boolean, nil] Whether to enable strict schema adherence when generating the output.
  74. end
  75. end
  76. end
  77. end

openai-ruby/lib/openai/models/response_format_text.rb

100.0% lines covered

100.0% branches covered

4 relevant lines. 4 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class ResponseFormatText < OpenAI::Internal::Type::BaseModel
  5. # @!attribute type
  6. # The type of response format being defined. Always `text`.
  7. #
  8. # @return [Symbol, :text]
  9. 1 required :type, const: :text
  10. # @!method initialize(type: :text)
  11. # Default response format. Used to generate text responses.
  12. #
  13. # @param type [Symbol, :text] The type of response format being defined. Always `text`.
  14. end
  15. end
  16. end

openai-ruby/lib/openai/models/responses/computer_tool.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ComputerTool < OpenAI::Internal::Type::BaseModel
  6. # @!attribute display_height
  7. # The height of the computer display.
  8. #
  9. # @return [Integer]
  10. 1 required :display_height, Integer
  11. # @!attribute display_width
  12. # The width of the computer display.
  13. #
  14. # @return [Integer]
  15. 1 required :display_width, Integer
  16. # @!attribute environment
  17. # The type of computer environment to control.
  18. #
  19. # @return [Symbol, OpenAI::Models::Responses::ComputerTool::Environment]
  20. 1 required :environment, enum: -> { OpenAI::Responses::ComputerTool::Environment }
  21. # @!attribute type
  22. # The type of the computer use tool. Always `computer_use_preview`.
  23. #
  24. # @return [Symbol, :computer_use_preview]
  25. 1 required :type, const: :computer_use_preview
  26. # @!method initialize(display_height:, display_width:, environment:, type: :computer_use_preview)
  27. # A tool that controls a virtual computer. Learn more about the
  28. # [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
  29. #
  30. # @param display_height [Integer] The height of the computer display.
  31. #
  32. # @param display_width [Integer] The width of the computer display.
  33. #
  34. # @param environment [Symbol, OpenAI::Models::Responses::ComputerTool::Environment] The type of computer environment to control.
  35. #
  36. # @param type [Symbol, :computer_use_preview] The type of the computer use tool. Always `computer_use_preview`.
  37. # The type of computer environment to control.
  38. #
  39. # @see OpenAI::Models::Responses::ComputerTool#environment
  40. 1 module Environment
  41. 1 extend OpenAI::Internal::Type::Enum
  42. 1 WINDOWS = :windows
  43. 1 MAC = :mac
  44. 1 LINUX = :linux
  45. 1 UBUNTU = :ubuntu
  46. 1 BROWSER = :browser
  47. # @!method self.values
  48. # @return [Array<Symbol>]
  49. end
  50. end
  51. end
  52. end
  53. end

openai-ruby/lib/openai/models/responses/easy_input_message.rb

100.0% lines covered

100.0% branches covered

20 relevant lines. 20 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class EasyInputMessage < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content
  7. # Text, image, or audio input to the model, used to generate a response. Can also
  8. # contain previous assistant responses.
  9. #
  10. # @return [String, Array<OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile>]
  11. 1 required :content, union: -> { OpenAI::Responses::EasyInputMessage::Content }
  12. # @!attribute role
  13. # The role of the message input. One of `user`, `assistant`, `system`, or
  14. # `developer`.
  15. #
  16. # @return [Symbol, OpenAI::Models::Responses::EasyInputMessage::Role]
  17. 1 required :role, enum: -> { OpenAI::Responses::EasyInputMessage::Role }
  18. # @!attribute type
  19. # The type of the message input. Always `message`.
  20. #
  21. # @return [Symbol, OpenAI::Models::Responses::EasyInputMessage::Type, nil]
  22. 1 optional :type, enum: -> { OpenAI::Responses::EasyInputMessage::Type }
  23. # @!method initialize(content:, role:, type: nil)
  24. # Some parameter documentations has been truncated, see
  25. # {OpenAI::Models::Responses::EasyInputMessage} for more details.
  26. #
  27. # A message input to the model with a role indicating instruction following
  28. # hierarchy. Instructions given with the `developer` or `system` role take
  29. # precedence over instructions given with the `user` role. Messages with the
  30. # `assistant` role are presumed to have been generated by the model in previous
  31. # interactions.
  32. #
  33. # @param content [String, Array<OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile>] Text, image, or audio input to the model, used to generate a response.
  34. #
  35. # @param role [Symbol, OpenAI::Models::Responses::EasyInputMessage::Role] The role of the message input. One of `user`, `assistant`, `system`, or
  36. #
  37. # @param type [Symbol, OpenAI::Models::Responses::EasyInputMessage::Type] The type of the message input. Always `message`.
  38. # Text, image, or audio input to the model, used to generate a response. Can also
  39. # contain previous assistant responses.
  40. #
  41. # @see OpenAI::Models::Responses::EasyInputMessage#content
  42. 1 module Content
  43. 1 extend OpenAI::Internal::Type::Union
  44. # A text input to the model.
  45. 1 variant String
  46. # A list of one or many input items to the model, containing different content
  47. # types.
  48. 1 variant -> { OpenAI::Responses::ResponseInputMessageContentList }
  49. # @!method self.variants
  50. # @return [Array(String, Array<OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile>)]
  51. end
  52. # The role of the message input. One of `user`, `assistant`, `system`, or
  53. # `developer`.
  54. #
  55. # @see OpenAI::Models::Responses::EasyInputMessage#role
  56. 1 module Role
  57. 1 extend OpenAI::Internal::Type::Enum
  58. 1 USER = :user
  59. 1 ASSISTANT = :assistant
  60. 1 SYSTEM = :system
  61. 1 DEVELOPER = :developer
  62. # @!method self.values
  63. # @return [Array<Symbol>]
  64. end
  65. # The type of the message input. Always `message`.
  66. #
  67. # @see OpenAI::Models::Responses::EasyInputMessage#type
  68. 1 module Type
  69. 1 extend OpenAI::Internal::Type::Enum
  70. 1 MESSAGE = :message
  71. # @!method self.values
  72. # @return [Array<Symbol>]
  73. end
  74. end
  75. end
  76. end
  77. end

openai-ruby/lib/openai/models/responses/file_search_tool.rb

100.0% lines covered

100.0% branches covered

20 relevant lines. 20 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class FileSearchTool < OpenAI::Internal::Type::BaseModel
  6. # @!attribute type
  7. # The type of the file search tool. Always `file_search`.
  8. #
  9. # @return [Symbol, :file_search]
  10. 1 required :type, const: :file_search
  11. # @!attribute vector_store_ids
  12. # The IDs of the vector stores to search.
  13. #
  14. # @return [Array<String>]
  15. 1 required :vector_store_ids, OpenAI::Internal::Type::ArrayOf[String]
  16. # @!attribute filters
  17. # A filter to apply.
  18. #
  19. # @return [OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter, nil]
  20. 1 optional :filters, union: -> { OpenAI::Responses::FileSearchTool::Filters }, nil?: true
  21. # @!attribute max_num_results
  22. # The maximum number of results to return. This number should be between 1 and 50
  23. # inclusive.
  24. #
  25. # @return [Integer, nil]
  26. 1 optional :max_num_results, Integer
  27. # @!attribute ranking_options
  28. # Ranking options for search.
  29. #
  30. # @return [OpenAI::Models::Responses::FileSearchTool::RankingOptions, nil]
  31. 1 optional :ranking_options, -> { OpenAI::Responses::FileSearchTool::RankingOptions }
  32. # @!method initialize(vector_store_ids:, filters: nil, max_num_results: nil, ranking_options: nil, type: :file_search)
  33. # Some parameter documentations has been truncated, see
  34. # {OpenAI::Models::Responses::FileSearchTool} for more details.
  35. #
  36. # A tool that searches for relevant content from uploaded files. Learn more about
  37. # the
  38. # [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
  39. #
  40. # @param vector_store_ids [Array<String>] The IDs of the vector stores to search.
  41. #
  42. # @param filters [OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter, nil] A filter to apply.
  43. #
  44. # @param max_num_results [Integer] The maximum number of results to return. This number should be between 1 and 50
  45. #
  46. # @param ranking_options [OpenAI::Models::Responses::FileSearchTool::RankingOptions] Ranking options for search.
  47. #
  48. # @param type [Symbol, :file_search] The type of the file search tool. Always `file_search`.
  49. # A filter to apply.
  50. #
  51. # @see OpenAI::Models::Responses::FileSearchTool#filters
  52. 1 module Filters
  53. 1 extend OpenAI::Internal::Type::Union
  54. # A filter used to compare a specified attribute key to a given value using a defined comparison operation.
  55. 1 variant -> { OpenAI::ComparisonFilter }
  56. # Combine multiple filters using `and` or `or`.
  57. 1 variant -> { OpenAI::CompoundFilter }
  58. # @!method self.variants
  59. # @return [Array(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)]
  60. end
  61. # @see OpenAI::Models::Responses::FileSearchTool#ranking_options
  62. 1 class RankingOptions < OpenAI::Internal::Type::BaseModel
  63. # @!attribute ranker
  64. # The ranker to use for the file search.
  65. #
  66. # @return [Symbol, OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker, nil]
  67. 1 optional :ranker, enum: -> { OpenAI::Responses::FileSearchTool::RankingOptions::Ranker }
  68. # @!attribute score_threshold
  69. # The score threshold for the file search, a number between 0 and 1. Numbers
  70. # closer to 1 will attempt to return only the most relevant results, but may
  71. # return fewer results.
  72. #
  73. # @return [Float, nil]
  74. 1 optional :score_threshold, Float
  75. # @!method initialize(ranker: nil, score_threshold: nil)
  76. # Some parameter documentations has been truncated, see
  77. # {OpenAI::Models::Responses::FileSearchTool::RankingOptions} for more details.
  78. #
  79. # Ranking options for search.
  80. #
  81. # @param ranker [Symbol, OpenAI::Models::Responses::FileSearchTool::RankingOptions::Ranker] The ranker to use for the file search.
  82. #
  83. # @param score_threshold [Float] The score threshold for the file search, a number between 0 and 1. Numbers close
  84. # The ranker to use for the file search.
  85. #
  86. # @see OpenAI::Models::Responses::FileSearchTool::RankingOptions#ranker
  87. 1 module Ranker
  88. 1 extend OpenAI::Internal::Type::Enum
  89. 1 AUTO = :auto
  90. 1 DEFAULT_2024_11_15 = :"default-2024-11-15"
  91. # @!method self.values
  92. # @return [Array<Symbol>]
  93. end
  94. end
  95. end
  96. end
  97. end
  98. end

openai-ruby/lib/openai/models/responses/function_tool.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class FunctionTool < OpenAI::Internal::Type::BaseModel
  6. # @!attribute name
  7. # The name of the function to call.
  8. #
  9. # @return [String]
  10. 1 required :name, String
  11. # @!attribute parameters
  12. # A JSON schema object describing the parameters of the function.
  13. #
  14. # @return [Hash{Symbol=>Object}, nil]
  15. 1 required :parameters,
  16. union: OpenAI::UnionOf[
  17. OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown],
  18. OpenAI::StructuredOutput::JsonSchemaConverter
  19. ],
  20. nil?: true
  21. # @!attribute strict
  22. # Whether to enforce strict parameter validation. Default `true`.
  23. #
  24. # @return [Boolean, nil]
  25. 1 required :strict, OpenAI::Internal::Type::Boolean, nil?: true
  26. # @!attribute type
  27. # The type of the function tool. Always `function`.
  28. #
  29. # @return [Symbol, :function]
  30. 1 required :type, const: :function
  31. # @!attribute description
  32. # A description of the function. Used by the model to determine whether or not to
  33. # call the function.
  34. #
  35. # @return [String, nil]
  36. 1 optional :description, String, nil?: true
  37. # @!method initialize(name:, parameters:, strict:, description: nil, type: :function)
  38. # Some parameter documentations has been truncated, see
  39. # {OpenAI::Models::Responses::FunctionTool} for more details.
  40. #
  41. # Defines a function in your own code the model can choose to call. Learn more
  42. # about
  43. # [function calling](https://platform.openai.com/docs/guides/function-calling).
  44. #
  45. # @param name [String] The name of the function to call.
  46. #
  47. # @param parameters [Hash{Symbol=>Object}, nil] A JSON schema object describing the parameters of the function.
  48. #
  49. # @param strict [Boolean, nil] Whether to enforce strict parameter validation. Default `true`.
  50. #
  51. # @param description [String, nil] A description of the function. Used by the model to determine whether or not to
  52. #
  53. # @param type [Symbol, :function] The type of the function tool. Always `function`.
  54. end
  55. end
  56. end
  57. end

openai-ruby/lib/openai/models/responses/input_item_list_params.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # @see OpenAI::Resources::Responses::InputItems#list
  6. 1 class InputItemListParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute after
  10. # An item ID to list items after, used in pagination.
  11. #
  12. # @return [String, nil]
  13. 1 optional :after, String
  14. # @!attribute before
  15. # An item ID to list items before, used in pagination.
  16. #
  17. # @return [String, nil]
  18. 1 optional :before, String
  19. # @!attribute include
  20. # Additional fields to include in the response. See the `include` parameter for
  21. # Response creation above for more information.
  22. #
  23. # @return [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>, nil]
  24. 1 optional :include, -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Responses::ResponseIncludable] }
  25. # @!attribute limit
  26. # A limit on the number of objects to be returned. Limit can range between 1 and
  27. # 100, and the default is 20.
  28. #
  29. # @return [Integer, nil]
  30. 1 optional :limit, Integer
  31. # @!attribute order
  32. # The order to return the input items in. Default is `desc`.
  33. #
  34. # - `asc`: Return the input items in ascending order.
  35. # - `desc`: Return the input items in descending order.
  36. #
  37. # @return [Symbol, OpenAI::Models::Responses::InputItemListParams::Order, nil]
  38. 1 optional :order, enum: -> { OpenAI::Responses::InputItemListParams::Order }
  39. # @!method initialize(after: nil, before: nil, include: nil, limit: nil, order: nil, request_options: {})
  40. # Some parameter documentations has been truncated, see
  41. # {OpenAI::Models::Responses::InputItemListParams} for more details.
  42. #
  43. # @param after [String] An item ID to list items after, used in pagination.
  44. #
  45. # @param before [String] An item ID to list items before, used in pagination.
  46. #
  47. # @param include [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>] Additional fields to include in the response. See the `include`
  48. #
  49. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between
  50. #
  51. # @param order [Symbol, OpenAI::Models::Responses::InputItemListParams::Order] The order to return the input items in. Default is `desc`.
  52. #
  53. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  54. # The order to return the input items in. Default is `desc`.
  55. #
  56. # - `asc`: Return the input items in ascending order.
  57. # - `desc`: Return the input items in descending order.
  58. 1 module Order
  59. 1 extend OpenAI::Internal::Type::Enum
  60. 1 ASC = :asc
  61. 1 DESC = :desc
  62. # @!method self.values
  63. # @return [Array<Symbol>]
  64. end
  65. end
  66. end
  67. end
  68. end

openai-ruby/lib/openai/models/responses/response.rb

89.86% lines covered

0.0% branches covered

69 relevant lines. 62 lines covered and 7 lines missed.
4 total branches, 0 branches covered and 4 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # @see OpenAI::Resources::Responses#create
  6. #
  7. # @see OpenAI::Resources::Responses#stream_raw
  8. 1 class Response < OpenAI::Internal::Type::BaseModel
  9. # @!attribute id
  10. # Unique identifier for this Response.
  11. #
  12. # @return [String]
  13. 1 required :id, String
  14. # @!attribute created_at
  15. # Unix timestamp (in seconds) of when this Response was created.
  16. #
  17. # @return [Float]
  18. 1 required :created_at, Float
  19. # @!attribute error
  20. # An error object returned when the model fails to generate a Response.
  21. #
  22. # @return [OpenAI::Models::Responses::ResponseError, nil]
  23. 1 required :error, -> { OpenAI::Responses::ResponseError }, nil?: true
  24. # @!attribute incomplete_details
  25. # Details about why the response is incomplete.
  26. #
  27. # @return [OpenAI::Models::Responses::Response::IncompleteDetails, nil]
  28. 1 required :incomplete_details, -> { OpenAI::Responses::Response::IncompleteDetails }, nil?: true
  29. # @!attribute instructions
  30. # A system (or developer) message inserted into the model's context.
  31. #
  32. # When using along with `previous_response_id`, the instructions from a previous
  33. # response will not be carried over to the next response. This makes it simple to
  34. # swap out system (or developer) messages in new responses.
  35. #
  36. # @return [String, Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference>, nil]
  37. 1 required :instructions, union: -> { OpenAI::Responses::Response::Instructions }, nil?: true
  38. # @!attribute metadata
  39. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  40. # for storing additional information about the object in a structured format, and
  41. # querying for objects via API or the dashboard.
  42. #
  43. # Keys are strings with a maximum length of 64 characters. Values are strings with
  44. # a maximum length of 512 characters.
  45. #
  46. # @return [Hash{Symbol=>String}, nil]
  47. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  48. # @!attribute model
  49. # Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
  50. # wide range of models with different capabilities, performance characteristics,
  51. # and price points. Refer to the
  52. # [model guide](https://platform.openai.com/docs/models) to browse and compare
  53. # available models.
  54. #
  55. # @return [String, Symbol, OpenAI::Models::ChatModel, OpenAI::Models::ResponsesModel::ResponsesOnlyModel]
  56. 1 required :model, union: -> { OpenAI::ResponsesModel }
  57. # @!attribute object
  58. # The object type of this resource - always set to `response`.
  59. #
  60. # @return [Symbol, :response]
  61. 1 required :object, const: :response
  62. # @!attribute output
  63. # An array of content items generated by the model.
  64. #
  65. # - The length and order of items in the `output` array is dependent on the
  66. # model's response.
  67. # - Rather than accessing the first item in the `output` array and assuming it's
  68. # an `assistant` message with the content generated by the model, you might
  69. # consider using the `output_text` property where supported in SDKs.
  70. #
  71. # @return [Array<OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall, OpenAI::Models::Responses::ResponseOutputItem::McpCall, OpenAI::Models::Responses::ResponseOutputItem::McpListTools, OpenAI::Models::Responses::ResponseOutputItem::McpApprovalRequest>]
  72. 1 required :output, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::ResponseOutputItem] }
  73. # @!attribute parallel_tool_calls
  74. # Whether to allow the model to run tool calls in parallel.
  75. #
  76. # @return [Boolean]
  77. 1 required :parallel_tool_calls, OpenAI::Internal::Type::Boolean
  78. # @!attribute temperature
  79. # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  80. # make the output more random, while lower values like 0.2 will make it more
  81. # focused and deterministic. We generally recommend altering this or `top_p` but
  82. # not both.
  83. #
  84. # @return [Float, nil]
  85. 1 required :temperature, Float, nil?: true
  86. # @!attribute tool_choice
  87. # How the model should select which tool (or tools) to use when generating a
  88. # response. See the `tools` parameter to see how to specify which tools the model
  89. # can call.
  90. #
  91. # @return [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp]
  92. 1 required :tool_choice, union: -> { OpenAI::Responses::Response::ToolChoice }
  93. # @!attribute tools
  94. # An array of tools the model may call while generating a response. You can
  95. # specify which tool to use by setting the `tool_choice` parameter.
  96. #
  97. # The two categories of tools you can provide the model are:
  98. #
  99. # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
  100. # capabilities, like
  101. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  102. # [file search](https://platform.openai.com/docs/guides/tools-file-search).
  103. # Learn more about
  104. # [built-in tools](https://platform.openai.com/docs/guides/tools).
  105. # - **Function calls (custom tools)**: Functions that are defined by you, enabling
  106. # the model to call your own code. Learn more about
  107. # [function calling](https://platform.openai.com/docs/guides/function-calling).
  108. #
  109. # @return [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>]
  110. 1 required :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] }
  111. # @!attribute top_p
  112. # An alternative to sampling with temperature, called nucleus sampling, where the
  113. # model considers the results of the tokens with top_p probability mass. So 0.1
  114. # means only the tokens comprising the top 10% probability mass are considered.
  115. #
  116. # We generally recommend altering this or `temperature` but not both.
  117. #
  118. # @return [Float, nil]
  119. 1 required :top_p, Float, nil?: true
  120. # @!attribute background
  121. # Whether to run the model response in the background.
  122. # [Learn more](https://platform.openai.com/docs/guides/background).
  123. #
  124. # @return [Boolean, nil]
  125. 1 optional :background, OpenAI::Internal::Type::Boolean, nil?: true
  126. # @!attribute max_output_tokens
  127. # An upper bound for the number of tokens that can be generated for a response,
  128. # including visible output tokens and
  129. # [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
  130. #
  131. # @return [Integer, nil]
  132. 1 optional :max_output_tokens, Integer, nil?: true
  133. # @!attribute max_tool_calls
  134. # The maximum number of total calls to built-in tools that can be processed in a
  135. # response. This maximum number applies across all built-in tool calls, not per
  136. # individual tool. Any further attempts to call a tool by the model will be
  137. # ignored.
  138. #
  139. # @return [Integer, nil]
  140. 1 optional :max_tool_calls, Integer, nil?: true
  141. # @!attribute previous_response_id
  142. # The unique ID of the previous response to the model. Use this to create
  143. # multi-turn conversations. Learn more about
  144. # [conversation state](https://platform.openai.com/docs/guides/conversation-state).
  145. #
  146. # @return [String, nil]
  147. 1 optional :previous_response_id, String, nil?: true
  148. # @!attribute prompt
  149. # Reference to a prompt template and its variables.
  150. # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
  151. #
  152. # @return [OpenAI::Models::Responses::ResponsePrompt, nil]
  153. 1 optional :prompt, -> { OpenAI::Responses::ResponsePrompt }, nil?: true
  154. # @!attribute prompt_cache_key
  155. # Used by OpenAI to cache responses for similar requests to optimize your cache
  156. # hit rates. Replaces the `user` field.
  157. # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
  158. #
  159. # @return [String, nil]
  160. 1 optional :prompt_cache_key, String
  161. # @!attribute reasoning
  162. # **o-series models only**
  163. #
  164. # Configuration options for
  165. # [reasoning models](https://platform.openai.com/docs/guides/reasoning).
  166. #
  167. # @return [OpenAI::Models::Reasoning, nil]
  168. 1 optional :reasoning, -> { OpenAI::Reasoning }, nil?: true
  169. # @!attribute safety_identifier
  170. # A stable identifier used to help detect users of your application that may be
  171. # violating OpenAI's usage policies. The IDs should be a string that uniquely
  172. # identifies each user. We recommend hashing their username or email address, in
  173. # order to avoid sending us any identifying information.
  174. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
  175. #
  176. # @return [String, nil]
  177. 1 optional :safety_identifier, String
  178. # @!attribute service_tier
  179. # Specifies the processing type used for serving the request.
  180. #
  181. # - If set to 'auto', then the request will be processed with the service tier
  182. # configured in the Project settings. Unless otherwise configured, the Project
  183. # will use 'default'.
  184. # - If set to 'default', then the request will be processed with the standard
  185. # pricing and performance for the selected model.
  186. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  187. # 'priority', then the request will be processed with the corresponding service
  188. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  189. # Priority processing.
  190. # - When not set, the default behavior is 'auto'.
  191. #
  192. # When the `service_tier` parameter is set, the response body will include the
  193. # `service_tier` value based on the processing mode actually used to serve the
  194. # request. This response value may be different from the value set in the
  195. # parameter.
  196. #
  197. # @return [Symbol, OpenAI::Models::Responses::Response::ServiceTier, nil]
  198. 1 optional :service_tier, enum: -> { OpenAI::Responses::Response::ServiceTier }, nil?: true
  199. # @!attribute status
  200. # The status of the response generation. One of `completed`, `failed`,
  201. # `in_progress`, `cancelled`, `queued`, or `incomplete`.
  202. #
  203. # @return [Symbol, OpenAI::Models::Responses::ResponseStatus, nil]
  204. 1 optional :status, enum: -> { OpenAI::Responses::ResponseStatus }
  205. # @!attribute text
  206. # Configuration options for a text response from the model. Can be plain text or
  207. # structured JSON data. Learn more:
  208. #
  209. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  210. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  211. #
  212. # @return [OpenAI::Models::Responses::ResponseTextConfig, nil]
  213. 1 optional :text, -> { OpenAI::Responses::ResponseTextConfig }
  214. # @!attribute top_logprobs
  215. # An integer between 0 and 20 specifying the number of most likely tokens to
  216. # return at each token position, each with an associated log probability.
  217. #
  218. # @return [Integer, nil]
  219. 1 optional :top_logprobs, Integer, nil?: true
  220. # @!attribute truncation
  221. # The truncation strategy to use for the model response.
  222. #
  223. # - `auto`: If the context of this response and previous ones exceeds the model's
  224. # context window size, the model will truncate the response to fit the context
  225. # window by dropping input items in the middle of the conversation.
  226. # - `disabled` (default): If a model response will exceed the context window size
  227. # for a model, the request will fail with a 400 error.
  228. #
  229. # @return [Symbol, OpenAI::Models::Responses::Response::Truncation, nil]
  230. 1 optional :truncation, enum: -> { OpenAI::Responses::Response::Truncation }, nil?: true
  231. # @!attribute usage
  232. # Represents token usage details including input tokens, output tokens, a
  233. # breakdown of output tokens, and the total tokens used.
  234. #
  235. # @return [OpenAI::Models::Responses::ResponseUsage, nil]
  236. 1 optional :usage, -> { OpenAI::Responses::ResponseUsage }
  237. # @!attribute user
  238. # @deprecated
  239. #
  240. # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  241. # `prompt_cache_key` instead to maintain caching optimizations. A stable
  242. # identifier for your end-users. Used to boost cache hit rates by better bucketing
  243. # similar requests and to help OpenAI detect and prevent abuse.
  244. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
  245. #
  246. # @return [String, nil]
  247. 1 optional :user, String
  248. # Convenience property that aggregates all `output_text` items from the `output` list.
  249. #
  250. # If no `output_text` content blocks exist, then an empty string is returned.
  251. #
  252. # @return [String]
  253. 1 def output_text
  254. texts = []
  255. output.each do |item|
  256. else: 0 then: 0 next unless item.type == :message
  257. item.content.each do |content|
  258. then: 0 else: 0 if content.type == :output_text
  259. texts << content.text
  260. end
  261. end
  262. end
  263. texts.join
  264. end
  265. # @!method initialize(id:, created_at:, error:, incomplete_details:, instructions:, metadata:, model:, output:, parallel_tool_calls:, temperature:, tool_choice:, tools:, top_p:, background: nil, max_output_tokens: nil, max_tool_calls: nil, previous_response_id: nil, prompt: nil, reasoning: nil, service_tier: nil, status: nil, text: nil, top_logprobs: nil, truncation: nil, usage: nil, user: nil, object: :response)
  266. # Some parameter documentations has been truncated, see
  267. # {OpenAI::Models::Responses::Response} for more details.
  268. #
  269. # @param id [String] Unique identifier for this Response.
  270. #
  271. # @param created_at [Float] Unix timestamp (in seconds) of when this Response was created.
  272. #
  273. # @param error [OpenAI::Models::Responses::ResponseError, nil] An error object returned when the model fails to generate a Response.
  274. #
  275. # @param incomplete_details [OpenAI::Models::Responses::Response::IncompleteDetails, nil] Details about why the response is incomplete.
  276. #
  277. # @param instructions [String, Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference>, nil] A system (or developer) message inserted into the model's context.
  278. #
  279. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  280. #
  281. # @param model [String, Symbol, OpenAI::Models::ChatModel, OpenAI::Models::ResponsesModel::ResponsesOnlyModel] Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
  282. #
  283. # @param output [Array<OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall, OpenAI::Models::Responses::ResponseOutputItem::McpCall, OpenAI::Models::Responses::ResponseOutputItem::McpListTools, OpenAI::Models::Responses::ResponseOutputItem::McpApprovalRequest>] An array of content items generated by the model.
  284. #
  285. # @param parallel_tool_calls [Boolean] Whether to allow the model to run tool calls in parallel.
  286. #
  287. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  288. #
  289. # @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp] How the model should select which tool (or tools) to use when generating
  290. #
  291. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  292. #
  293. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling,
  294. #
  295. # @param background [Boolean, nil] Whether to run the model response in the background.
  296. #
  297. # @param max_output_tokens [Integer, nil] An upper bound for the number of tokens that can be generated for a response, in
  298. #
  299. # @param max_tool_calls [Integer, nil] The maximum number of total calls to built-in tools that can be processed in a r
  300. #
  301. # @param previous_response_id [String, nil] The unique ID of the previous response to the model. Use this to
  302. #
  303. # @param prompt [OpenAI::Models::Responses::ResponsePrompt, nil] Reference to a prompt template and its variables.
  304. #
  305. # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi
  306. #
  307. # @param reasoning [OpenAI::Models::Reasoning, nil] **o-series models only**
  308. #
  309. # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi
  310. #
  311. # @param service_tier [Symbol, OpenAI::Models::Responses::Response::ServiceTier, nil] Specifies the processing type used for serving the request.
  312. #
  313. # @param status [Symbol, OpenAI::Models::Responses::ResponseStatus] The status of the response generation. One of `completed`, `failed`,
  314. #
  315. # @param text [OpenAI::Models::Responses::ResponseTextConfig] Configuration options for a text response from the model. Can be plain
  316. #
  317. # @param top_logprobs [Integer, nil] An integer between 0 and 20 specifying the number of most likely tokens to
  318. #
  319. # @param truncation [Symbol, OpenAI::Models::Responses::Response::Truncation, nil] The truncation strategy to use for the model response.
  320. #
  321. # @param usage [OpenAI::Models::Responses::ResponseUsage] Represents token usage details including input tokens, output tokens,
  322. #
  323. # @param user [String] This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  324. #
  325. # @param object [Symbol, :response] The object type of this resource - always set to `response`.
  326. # @see OpenAI::Models::Responses::Response#incomplete_details
  327. 1 class IncompleteDetails < OpenAI::Internal::Type::BaseModel
  328. # @!attribute reason
  329. # The reason why the response is incomplete.
  330. #
  331. # @return [Symbol, OpenAI::Models::Responses::Response::IncompleteDetails::Reason, nil]
  332. 1 optional :reason, enum: -> { OpenAI::Responses::Response::IncompleteDetails::Reason }
  333. # @!method initialize(reason: nil)
  334. # Details about why the response is incomplete.
  335. #
  336. # @param reason [Symbol, OpenAI::Models::Responses::Response::IncompleteDetails::Reason] The reason why the response is incomplete.
  337. # The reason why the response is incomplete.
  338. #
  339. # @see OpenAI::Models::Responses::Response::IncompleteDetails#reason
  340. 1 module Reason
  341. 1 extend OpenAI::Internal::Type::Enum
  342. 1 MAX_OUTPUT_TOKENS = :max_output_tokens
  343. 1 CONTENT_FILTER = :content_filter
  344. # @!method self.values
  345. # @return [Array<Symbol>]
  346. end
  347. end
  348. # A system (or developer) message inserted into the model's context.
  349. #
  350. # When using along with `previous_response_id`, the instructions from a previous
  351. # response will not be carried over to the next response. This makes it simple to
  352. # swap out system (or developer) messages in new responses.
  353. #
  354. # @see OpenAI::Models::Responses::Response#instructions
  355. 1 module Instructions
  356. 1 extend OpenAI::Internal::Type::Union
  357. # A text input to the model, equivalent to a text input with the
  358. # `developer` role.
  359. 1 variant String
  360. # A list of one or many input items to the model, containing
  361. # different content types.
  362. 1 variant -> { OpenAI::Models::Responses::Response::Instructions::ResponseInputItemArray }
  363. # @!method self.variants
  364. # @return [Array(String, Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference>)]
  365. # @type [OpenAI::Internal::Type::Converter]
  366. ResponseInputItemArray =
  367. 1 OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Responses::ResponseInputItem }]
  368. end
  369. # How the model should select which tool (or tools) to use when generating a
  370. # response. See the `tools` parameter to see how to specify which tools the model
  371. # can call.
  372. #
  373. # @see OpenAI::Models::Responses::Response#tool_choice
  374. 1 module ToolChoice
  375. 1 extend OpenAI::Internal::Type::Union
  376. # Controls which (if any) tool is called by the model.
  377. #
  378. # `none` means the model will not call any tool and instead generates a message.
  379. #
  380. # `auto` means the model can pick between generating a message or calling one or
  381. # more tools.
  382. #
  383. # `required` means the model must call one or more tools.
  384. 1 variant enum: -> { OpenAI::Responses::ToolChoiceOptions }
  385. # Indicates that the model should use a built-in tool to generate a response.
  386. # [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
  387. 1 variant -> { OpenAI::Responses::ToolChoiceTypes }
  388. # Use this option to force the model to call a specific function.
  389. 1 variant -> { OpenAI::Responses::ToolChoiceFunction }
  390. # Use this option to force the model to call a specific tool on a remote MCP server.
  391. 1 variant -> { OpenAI::Responses::ToolChoiceMcp }
  392. # @!method self.variants
  393. # @return [Array(Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp)]
  394. end
  395. # Specifies the processing type used for serving the request.
  396. #
  397. # - If set to 'auto', then the request will be processed with the service tier
  398. # configured in the Project settings. Unless otherwise configured, the Project
  399. # will use 'default'.
  400. # - If set to 'default', then the request will be processed with the standard
  401. # pricing and performance for the selected model.
  402. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  403. # 'priority', then the request will be processed with the corresponding service
  404. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  405. # Priority processing.
  406. # - When not set, the default behavior is 'auto'.
  407. #
  408. # When the `service_tier` parameter is set, the response body will include the
  409. # `service_tier` value based on the processing mode actually used to serve the
  410. # request. This response value may be different from the value set in the
  411. # parameter.
  412. #
  413. # @see OpenAI::Models::Responses::Response#service_tier
  414. 1 module ServiceTier
  415. 1 extend OpenAI::Internal::Type::Enum
  416. 1 AUTO = :auto
  417. 1 DEFAULT = :default
  418. 1 FLEX = :flex
  419. 1 SCALE = :scale
  420. 1 PRIORITY = :priority
  421. # @!method self.values
  422. # @return [Array<Symbol>]
  423. end
  424. # The truncation strategy to use for the model response.
  425. #
  426. # - `auto`: If the context of this response and previous ones exceeds the model's
  427. # context window size, the model will truncate the response to fit the context
  428. # window by dropping input items in the middle of the conversation.
  429. # - `disabled` (default): If a model response will exceed the context window size
  430. # for a model, the request will fail with a 400 error.
  431. #
  432. # @see OpenAI::Models::Responses::Response#truncation
  433. 1 module Truncation
  434. 1 extend OpenAI::Internal::Type::Enum
  435. 1 AUTO = :auto
  436. 1 DISABLED = :disabled
  437. # @!method self.values
  438. # @return [Array<Symbol>]
  439. end
  440. end
  441. end
  442. end
  443. end

openai-ruby/lib/openai/models/responses/response_audio_delta_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseAudioDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute delta
  7. # A chunk of Base64 encoded response audio bytes.
  8. #
  9. # @return [String]
  10. 1 required :delta, String
  11. # @!attribute sequence_number
  12. # A sequence number for this chunk of the stream response.
  13. #
  14. # @return [Integer]
  15. 1 required :sequence_number, Integer
  16. # @!attribute type
  17. # The type of the event. Always `response.audio.delta`.
  18. #
  19. # @return [Symbol, :"response.audio.delta"]
  20. 1 required :type, const: :"response.audio.delta"
  21. # @!method initialize(delta:, sequence_number:, type: :"response.audio.delta")
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ResponseAudioDeltaEvent} for more details.
  24. #
  25. # Emitted when there is a partial audio response.
  26. #
  27. # @param delta [String] A chunk of Base64 encoded response audio bytes.
  28. #
  29. # @param sequence_number [Integer] A sequence number for this chunk of the stream response.
  30. #
  31. # @param type [Symbol, :"response.audio.delta"] The type of the event. Always `response.audio.delta`.
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/responses/response_audio_done_event.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseAudioDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute sequence_number
  7. # The sequence number of the delta.
  8. #
  9. # @return [Integer]
  10. 1 required :sequence_number, Integer
  11. # @!attribute type
  12. # The type of the event. Always `response.audio.done`.
  13. #
  14. # @return [Symbol, :"response.audio.done"]
  15. 1 required :type, const: :"response.audio.done"
  16. # @!method initialize(sequence_number:, type: :"response.audio.done")
  17. # Some parameter documentations has been truncated, see
  18. # {OpenAI::Models::Responses::ResponseAudioDoneEvent} for more details.
  19. #
  20. # Emitted when the audio response is complete.
  21. #
  22. # @param sequence_number [Integer] The sequence number of the delta.
  23. #
  24. # @param type [Symbol, :"response.audio.done"] The type of the event. Always `response.audio.done`.
  25. end
  26. end
  27. end
  28. end

openai-ruby/lib/openai/models/responses/response_audio_transcript_delta_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseAudioTranscriptDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute delta
  7. # The partial transcript of the audio response.
  8. #
  9. # @return [String]
  10. 1 required :delta, String
  11. # @!attribute sequence_number
  12. # The sequence number of this event.
  13. #
  14. # @return [Integer]
  15. 1 required :sequence_number, Integer
  16. # @!attribute type
  17. # The type of the event. Always `response.audio.transcript.delta`.
  18. #
  19. # @return [Symbol, :"response.audio.transcript.delta"]
  20. 1 required :type, const: :"response.audio.transcript.delta"
  21. # @!method initialize(delta:, sequence_number:, type: :"response.audio.transcript.delta")
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent} for more details.
  24. #
  25. # Emitted when there is a partial transcript of audio.
  26. #
  27. # @param delta [String] The partial transcript of the audio response.
  28. #
  29. # @param sequence_number [Integer] The sequence number of this event.
  30. #
  31. # @param type [Symbol, :"response.audio.transcript.delta"] The type of the event. Always `response.audio.transcript.delta`.
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/responses/response_audio_transcript_done_event.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseAudioTranscriptDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute sequence_number
  7. # The sequence number of this event.
  8. #
  9. # @return [Integer]
  10. 1 required :sequence_number, Integer
  11. # @!attribute type
  12. # The type of the event. Always `response.audio.transcript.done`.
  13. #
  14. # @return [Symbol, :"response.audio.transcript.done"]
  15. 1 required :type, const: :"response.audio.transcript.done"
  16. # @!method initialize(sequence_number:, type: :"response.audio.transcript.done")
  17. # Some parameter documentations has been truncated, see
  18. # {OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent} for more details.
  19. #
  20. # Emitted when the full audio transcript is completed.
  21. #
  22. # @param sequence_number [Integer] The sequence number of this event.
  23. #
  24. # @param type [Symbol, :"response.audio.transcript.done"] The type of the event. Always `response.audio.transcript.done`.
  25. end
  26. end
  27. end
  28. end

openai-ruby/lib/openai/models/responses/response_cancel_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # @see OpenAI::Resources::Responses#cancel
  6. 1 class ResponseCancelParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/responses/response_code_interpreter_call_code_delta_event.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseCodeInterpreterCallCodeDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute delta
  7. # The partial code snippet being streamed by the code interpreter.
  8. #
  9. # @return [String]
  10. 1 required :delta, String
  11. # @!attribute item_id
  12. # The unique identifier of the code interpreter tool call item.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute output_index
  17. # The index of the output item in the response for which the code is being
  18. # streamed.
  19. #
  20. # @return [Integer]
  21. 1 required :output_index, Integer
  22. # @!attribute sequence_number
  23. # The sequence number of this event, used to order streaming events.
  24. #
  25. # @return [Integer]
  26. 1 required :sequence_number, Integer
  27. # @!attribute type
  28. # The type of the event. Always `response.code_interpreter_call_code.delta`.
  29. #
  30. # @return [Symbol, :"response.code_interpreter_call_code.delta"]
  31. 1 required :type, const: :"response.code_interpreter_call_code.delta"
  32. # @!method initialize(delta:, item_id:, output_index:, sequence_number:, type: :"response.code_interpreter_call_code.delta")
  33. # Some parameter documentations has been truncated, see
  34. # {OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent} for more
  35. # details.
  36. #
  37. # Emitted when a partial code snippet is streamed by the code interpreter.
  38. #
  39. # @param delta [String] The partial code snippet being streamed by the code interpreter.
  40. #
  41. # @param item_id [String] The unique identifier of the code interpreter tool call item.
  42. #
  43. # @param output_index [Integer] The index of the output item in the response for which the code is being streame
  44. #
  45. # @param sequence_number [Integer] The sequence number of this event, used to order streaming events.
  46. #
  47. # @param type [Symbol, :"response.code_interpreter_call_code.delta"] The type of the event. Always `response.code_interpreter_call_code.delta`.
  48. end
  49. end
  50. end
  51. end

openai-ruby/lib/openai/models/responses/response_code_interpreter_call_code_done_event.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseCodeInterpreterCallCodeDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute code
  7. # The final code snippet output by the code interpreter.
  8. #
  9. # @return [String]
  10. 1 required :code, String
  11. # @!attribute item_id
  12. # The unique identifier of the code interpreter tool call item.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute output_index
  17. # The index of the output item in the response for which the code is finalized.
  18. #
  19. # @return [Integer]
  20. 1 required :output_index, Integer
  21. # @!attribute sequence_number
  22. # The sequence number of this event, used to order streaming events.
  23. #
  24. # @return [Integer]
  25. 1 required :sequence_number, Integer
  26. # @!attribute type
  27. # The type of the event. Always `response.code_interpreter_call_code.done`.
  28. #
  29. # @return [Symbol, :"response.code_interpreter_call_code.done"]
  30. 1 required :type, const: :"response.code_interpreter_call_code.done"
  31. # @!method initialize(code:, item_id:, output_index:, sequence_number:, type: :"response.code_interpreter_call_code.done")
  32. # Emitted when the code snippet is finalized by the code interpreter.
  33. #
  34. # @param code [String] The final code snippet output by the code interpreter.
  35. #
  36. # @param item_id [String] The unique identifier of the code interpreter tool call item.
  37. #
  38. # @param output_index [Integer] The index of the output item in the response for which the code is finalized.
  39. #
  40. # @param sequence_number [Integer] The sequence number of this event, used to order streaming events.
  41. #
  42. # @param type [Symbol, :"response.code_interpreter_call_code.done"] The type of the event. Always `response.code_interpreter_call_code.done`.
  43. end
  44. end
  45. end
  46. end

openai-ruby/lib/openai/models/responses/response_code_interpreter_call_completed_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseCodeInterpreterCallCompletedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The unique identifier of the code interpreter tool call item.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item in the response for which the code interpreter call
  13. # is completed.
  14. #
  15. # @return [Integer]
  16. 1 required :output_index, Integer
  17. # @!attribute sequence_number
  18. # The sequence number of this event, used to order streaming events.
  19. #
  20. # @return [Integer]
  21. 1 required :sequence_number, Integer
  22. # @!attribute type
  23. # The type of the event. Always `response.code_interpreter_call.completed`.
  24. #
  25. # @return [Symbol, :"response.code_interpreter_call.completed"]
  26. 1 required :type, const: :"response.code_interpreter_call.completed"
  27. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.code_interpreter_call.completed")
  28. # Some parameter documentations has been truncated, see
  29. # {OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent} for more
  30. # details.
  31. #
  32. # Emitted when the code interpreter call is completed.
  33. #
  34. # @param item_id [String] The unique identifier of the code interpreter tool call item.
  35. #
  36. # @param output_index [Integer] The index of the output item in the response for which the code interpreter call
  37. #
  38. # @param sequence_number [Integer] The sequence number of this event, used to order streaming events.
  39. #
  40. # @param type [Symbol, :"response.code_interpreter_call.completed"] The type of the event. Always `response.code_interpreter_call.completed`.
  41. end
  42. end
  43. end
  44. end

openai-ruby/lib/openai/models/responses/response_code_interpreter_call_in_progress_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseCodeInterpreterCallInProgressEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The unique identifier of the code interpreter tool call item.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item in the response for which the code interpreter call
  13. # is in progress.
  14. #
  15. # @return [Integer]
  16. 1 required :output_index, Integer
  17. # @!attribute sequence_number
  18. # The sequence number of this event, used to order streaming events.
  19. #
  20. # @return [Integer]
  21. 1 required :sequence_number, Integer
  22. # @!attribute type
  23. # The type of the event. Always `response.code_interpreter_call.in_progress`.
  24. #
  25. # @return [Symbol, :"response.code_interpreter_call.in_progress"]
  26. 1 required :type, const: :"response.code_interpreter_call.in_progress"
  27. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.code_interpreter_call.in_progress")
  28. # Some parameter documentations has been truncated, see
  29. # {OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent} for more
  30. # details.
  31. #
  32. # Emitted when a code interpreter call is in progress.
  33. #
  34. # @param item_id [String] The unique identifier of the code interpreter tool call item.
  35. #
  36. # @param output_index [Integer] The index of the output item in the response for which the code interpreter call
  37. #
  38. # @param sequence_number [Integer] The sequence number of this event, used to order streaming events.
  39. #
  40. # @param type [Symbol, :"response.code_interpreter_call.in_progress"] The type of the event. Always `response.code_interpreter_call.in_progress`.
  41. end
  42. end
  43. end
  44. end

openai-ruby/lib/openai/models/responses/response_code_interpreter_call_interpreting_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseCodeInterpreterCallInterpretingEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The unique identifier of the code interpreter tool call item.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item in the response for which the code interpreter is
  13. # interpreting code.
  14. #
  15. # @return [Integer]
  16. 1 required :output_index, Integer
  17. # @!attribute sequence_number
  18. # The sequence number of this event, used to order streaming events.
  19. #
  20. # @return [Integer]
  21. 1 required :sequence_number, Integer
  22. # @!attribute type
  23. # The type of the event. Always `response.code_interpreter_call.interpreting`.
  24. #
  25. # @return [Symbol, :"response.code_interpreter_call.interpreting"]
  26. 1 required :type, const: :"response.code_interpreter_call.interpreting"
  27. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.code_interpreter_call.interpreting")
  28. # Some parameter documentations has been truncated, see
  29. # {OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent} for
  30. # more details.
  31. #
  32. # Emitted when the code interpreter is actively interpreting the code snippet.
  33. #
  34. # @param item_id [String] The unique identifier of the code interpreter tool call item.
  35. #
  36. # @param output_index [Integer] The index of the output item in the response for which the code interpreter is i
  37. #
  38. # @param sequence_number [Integer] The sequence number of this event, used to order streaming events.
  39. #
  40. # @param type [Symbol, :"response.code_interpreter_call.interpreting"] The type of the event. Always `response.code_interpreter_call.interpreting`.
  41. end
  42. end
  43. end
  44. end

openai-ruby/lib/openai/models/responses/response_code_interpreter_tool_call.rb

96.55% lines covered

100.0% branches covered

29 relevant lines. 28 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseCodeInterpreterToolCall < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the code interpreter tool call.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute code
  12. # The code to run, or null if not available.
  13. #
  14. # @return [String, nil]
  15. 1 required :code, String, nil?: true
  16. # @!attribute container_id
  17. # The ID of the container used to run the code.
  18. #
  19. # @return [String]
  20. 1 required :container_id, String
  21. # @!attribute outputs
  22. # The outputs generated by the code interpreter, such as logs or images. Can be
  23. # null if no outputs are available.
  24. #
  25. # @return [Array<OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Output::Logs, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Output::Image>, nil]
  26. 1 required :outputs,
  27. -> {
  28. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::ResponseCodeInterpreterToolCall::Output]
  29. },
  30. nil?: true
  31. # @!attribute status
  32. # The status of the code interpreter tool call. Valid values are `in_progress`,
  33. # `completed`, `incomplete`, `interpreting`, and `failed`.
  34. #
  35. # @return [Symbol, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status]
  36. 1 required :status, enum: -> { OpenAI::Responses::ResponseCodeInterpreterToolCall::Status }
  37. # @!attribute type
  38. # The type of the code interpreter tool call. Always `code_interpreter_call`.
  39. #
  40. # @return [Symbol, :code_interpreter_call]
  41. 1 required :type, const: :code_interpreter_call
  42. # @!method initialize(id:, code:, container_id:, outputs:, status:, type: :code_interpreter_call)
  43. # Some parameter documentations has been truncated, see
  44. # {OpenAI::Models::Responses::ResponseCodeInterpreterToolCall} for more details.
  45. #
  46. # A tool call to run code.
  47. #
  48. # @param id [String] The unique ID of the code interpreter tool call.
  49. #
  50. # @param code [String, nil] The code to run, or null if not available.
  51. #
  52. # @param container_id [String] The ID of the container used to run the code.
  53. #
  54. # @param outputs [Array<OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Output::Logs, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Output::Image>, nil] The outputs generated by the code interpreter, such as logs or images.
  55. #
  56. # @param status [Symbol, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Status] The status of the code interpreter tool call. Valid values are `in_progress`, `c
  57. #
  58. # @param type [Symbol, :code_interpreter_call] The type of the code interpreter tool call. Always `code_interpreter_call`.
  59. # The logs output from the code interpreter.
  60. 1 module Output
  61. 1 extend OpenAI::Internal::Type::Union
  62. 1 discriminator :type
  63. # The logs output from the code interpreter.
  64. 1 variant :logs, -> { OpenAI::Responses::ResponseCodeInterpreterToolCall::Output::Logs }
  65. # The image output from the code interpreter.
  66. 1 variant :image, -> { OpenAI::Responses::ResponseCodeInterpreterToolCall::Output::Image }
  67. 1 class Logs < OpenAI::Internal::Type::BaseModel
  68. # @!attribute logs
  69. # The logs output from the code interpreter.
  70. #
  71. # @return [String]
  72. 1 required :logs, String
  73. # @!attribute type
  74. # The type of the output. Always 'logs'.
  75. #
  76. # @return [Symbol, :logs]
  77. 1 required :type, const: :logs
  78. # @!method initialize(logs:, type: :logs)
  79. # The logs output from the code interpreter.
  80. #
  81. # @param logs [String] The logs output from the code interpreter.
  82. #
  83. # @param type [Symbol, :logs] The type of the output. Always 'logs'.
  84. end
  85. 1 class Image < OpenAI::Internal::Type::BaseModel
  86. # @!attribute type
  87. # The type of the output. Always 'image'.
  88. #
  89. # @return [Symbol, :image]
  90. 1 required :type, const: :image
  91. # @!attribute url
  92. # The URL of the image output from the code interpreter.
  93. #
  94. # @return [String]
  95. 1 required :url, String
  96. # @!method initialize(url:, type: :image)
  97. # The image output from the code interpreter.
  98. #
  99. # @param url [String] The URL of the image output from the code interpreter.
  100. #
  101. # @param type [Symbol, :image] The type of the output. Always 'image'.
  102. end
  103. # @!method self.variants
  104. # @return [Array(OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Output::Logs, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall::Output::Image)]
  105. end
  106. # The status of the code interpreter tool call. Valid values are `in_progress`,
  107. # `completed`, `incomplete`, `interpreting`, and `failed`.
  108. #
  109. # @see OpenAI::Models::Responses::ResponseCodeInterpreterToolCall#status
  110. 1 module Status
  111. 1 extend OpenAI::Internal::Type::Enum
  112. 1 IN_PROGRESS = :in_progress
  113. 1 COMPLETED = :completed
  114. 1 INCOMPLETE = :incomplete
  115. 1 INTERPRETING = :interpreting
  116. 1 FAILED = :failed
  117. # @!method self.values
  118. # @return [Array<Symbol>]
  119. end
  120. end
  121. end
  122. end
  123. end

openai-ruby/lib/openai/models/responses/response_completed_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseCompletedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute response
  7. # Properties of the completed response.
  8. #
  9. # @return [OpenAI::Models::Responses::Response]
  10. 1 required :response, -> { OpenAI::Responses::Response }
  11. # @!attribute sequence_number
  12. # The sequence number for this event.
  13. #
  14. # @return [Integer]
  15. 1 required :sequence_number, Integer
  16. # @!attribute type
  17. # The type of the event. Always `response.completed`.
  18. #
  19. # @return [Symbol, :"response.completed"]
  20. 1 required :type, const: :"response.completed"
  21. # @!method initialize(response:, sequence_number:, type: :"response.completed")
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ResponseCompletedEvent} for more details.
  24. #
  25. # Emitted when the model response is complete.
  26. #
  27. # @param response [OpenAI::Models::Responses::Response] Properties of the completed response.
  28. #
  29. # @param sequence_number [Integer] The sequence number for this event.
  30. #
  31. # @param type [Symbol, :"response.completed"] The type of the event. Always `response.completed`.
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/responses/response_computer_tool_call.rb

97.44% lines covered

100.0% branches covered

78 relevant lines. 76 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseComputerToolCall < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the computer call.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute action
  12. # A click action.
  13. #
  14. # @return [OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait]
  15. 1 required :action, union: -> { OpenAI::Responses::ResponseComputerToolCall::Action }
  16. # @!attribute call_id
  17. # An identifier used when responding to the tool call with output.
  18. #
  19. # @return [String]
  20. 1 required :call_id, String
  21. # @!attribute pending_safety_checks
  22. # The pending safety checks for the computer call.
  23. #
  24. # @return [Array<OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck>]
  25. 1 required :pending_safety_checks,
  26. -> {
  27. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseComputerToolCall::PendingSafetyCheck]
  28. }
  29. # @!attribute status
  30. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  31. # Populated when items are returned via API.
  32. #
  33. # @return [Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Status]
  34. 1 required :status, enum: -> { OpenAI::Responses::ResponseComputerToolCall::Status }
  35. # @!attribute type
  36. # The type of the computer call. Always `computer_call`.
  37. #
  38. # @return [Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Type]
  39. 1 required :type, enum: -> { OpenAI::Responses::ResponseComputerToolCall::Type }
  40. # @!method initialize(id:, action:, call_id:, pending_safety_checks:, status:, type:)
  41. # Some parameter documentations has been truncated, see
  42. # {OpenAI::Models::Responses::ResponseComputerToolCall} for more details.
  43. #
  44. # A tool call to a computer use tool. See the
  45. # [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use)
  46. # for more information.
  47. #
  48. # @param id [String] The unique ID of the computer call.
  49. #
  50. # @param action [OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait] A click action.
  51. #
  52. # @param call_id [String] An identifier used when responding to the tool call with output.
  53. #
  54. # @param pending_safety_checks [Array<OpenAI::Models::Responses::ResponseComputerToolCall::PendingSafetyCheck>] The pending safety checks for the computer call.
  55. #
  56. # @param status [Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Status] The status of the item. One of `in_progress`, `completed`, or
  57. #
  58. # @param type [Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Type] The type of the computer call. Always `computer_call`.
  59. # A click action.
  60. #
  61. # @see OpenAI::Models::Responses::ResponseComputerToolCall#action
  62. 1 module Action
  63. 1 extend OpenAI::Internal::Type::Union
  64. 1 discriminator :type
  65. # A click action.
  66. 1 variant :click, -> { OpenAI::Responses::ResponseComputerToolCall::Action::Click }
  67. # A double click action.
  68. 1 variant :double_click, -> { OpenAI::Responses::ResponseComputerToolCall::Action::DoubleClick }
  69. # A drag action.
  70. 1 variant :drag, -> { OpenAI::Responses::ResponseComputerToolCall::Action::Drag }
  71. # A collection of keypresses the model would like to perform.
  72. 1 variant :keypress, -> { OpenAI::Responses::ResponseComputerToolCall::Action::Keypress }
  73. # A mouse move action.
  74. 1 variant :move, -> { OpenAI::Responses::ResponseComputerToolCall::Action::Move }
  75. # A screenshot action.
  76. 1 variant :screenshot, -> { OpenAI::Responses::ResponseComputerToolCall::Action::Screenshot }
  77. # A scroll action.
  78. 1 variant :scroll, -> { OpenAI::Responses::ResponseComputerToolCall::Action::Scroll }
  79. # An action to type in text.
  80. 1 variant :type, -> { OpenAI::Responses::ResponseComputerToolCall::Action::Type }
  81. # A wait action.
  82. 1 variant :wait, -> { OpenAI::Responses::ResponseComputerToolCall::Action::Wait }
  83. 1 class Click < OpenAI::Internal::Type::BaseModel
  84. # @!attribute button
  85. # Indicates which mouse button was pressed during the click. One of `left`,
  86. # `right`, `wheel`, `back`, or `forward`.
  87. #
  88. # @return [Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button]
  89. 1 required :button, enum: -> { OpenAI::Responses::ResponseComputerToolCall::Action::Click::Button }
  90. # @!attribute type
  91. # Specifies the event type. For a click action, this property is always set to
  92. # `click`.
  93. #
  94. # @return [Symbol, :click]
  95. 1 required :type, const: :click
  96. # @!attribute x
  97. # The x-coordinate where the click occurred.
  98. #
  99. # @return [Integer]
  100. 1 required :x, Integer
  101. # @!attribute y_
  102. # The y-coordinate where the click occurred.
  103. #
  104. # @return [Integer]
  105. 1 required :y_, Integer, api_name: :y
  106. # @!method initialize(button:, x:, y_:, type: :click)
  107. # Some parameter documentations has been truncated, see
  108. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click} for more
  109. # details.
  110. #
  111. # A click action.
  112. #
  113. # @param button [Symbol, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click::Button] Indicates which mouse button was pressed during the click. One of `left`, `right
  114. #
  115. # @param x [Integer] The x-coordinate where the click occurred.
  116. #
  117. # @param y_ [Integer] The y-coordinate where the click occurred.
  118. #
  119. # @param type [Symbol, :click] Specifies the event type. For a click action, this property is
  120. # Indicates which mouse button was pressed during the click. One of `left`,
  121. # `right`, `wheel`, `back`, or `forward`.
  122. #
  123. # @see OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click#button
  124. 1 module Button
  125. 1 extend OpenAI::Internal::Type::Enum
  126. 1 LEFT = :left
  127. 1 RIGHT = :right
  128. 1 WHEEL = :wheel
  129. 1 BACK = :back
  130. 1 FORWARD = :forward
  131. # @!method self.values
  132. # @return [Array<Symbol>]
  133. end
  134. end
  135. 1 class DoubleClick < OpenAI::Internal::Type::BaseModel
  136. # @!attribute type
  137. # Specifies the event type. For a double click action, this property is always set
  138. # to `double_click`.
  139. #
  140. # @return [Symbol, :double_click]
  141. 1 required :type, const: :double_click
  142. # @!attribute x
  143. # The x-coordinate where the double click occurred.
  144. #
  145. # @return [Integer]
  146. 1 required :x, Integer
  147. # @!attribute y_
  148. # The y-coordinate where the double click occurred.
  149. #
  150. # @return [Integer]
  151. 1 required :y_, Integer, api_name: :y
  152. # @!method initialize(x:, y_:, type: :double_click)
  153. # Some parameter documentations has been truncated, see
  154. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick} for
  155. # more details.
  156. #
  157. # A double click action.
  158. #
  159. # @param x [Integer] The x-coordinate where the double click occurred.
  160. #
  161. # @param y_ [Integer] The y-coordinate where the double click occurred.
  162. #
  163. # @param type [Symbol, :double_click] Specifies the event type. For a double click action, this property is
  164. end
  165. 1 class Drag < OpenAI::Internal::Type::BaseModel
  166. # @!attribute path
  167. # An array of coordinates representing the path of the drag action. Coordinates
  168. # will appear as an array of objects, eg
  169. #
  170. # ```
  171. # [
  172. # { x: 100, y: 200 },
  173. # { x: 200, y: 300 }
  174. # ]
  175. # ```
  176. #
  177. # @return [Array<OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path>]
  178. 1 required :path,
  179. -> {
  180. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseComputerToolCall::Action::Drag::Path]
  181. }
  182. # @!attribute type
  183. # Specifies the event type. For a drag action, this property is always set to
  184. # `drag`.
  185. #
  186. # @return [Symbol, :drag]
  187. 1 required :type, const: :drag
  188. # @!method initialize(path:, type: :drag)
  189. # Some parameter documentations has been truncated, see
  190. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag} for more
  191. # details.
  192. #
  193. # A drag action.
  194. #
  195. # @param path [Array<OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path>] An array of coordinates representing the path of the drag action. Coordinates wi
  196. #
  197. # @param type [Symbol, :drag] Specifies the event type. For a drag action, this property is
  198. 1 class Path < OpenAI::Internal::Type::BaseModel
  199. # @!attribute x
  200. # The x-coordinate.
  201. #
  202. # @return [Integer]
  203. 1 required :x, Integer
  204. # @!attribute y_
  205. # The y-coordinate.
  206. #
  207. # @return [Integer]
  208. 1 required :y_, Integer, api_name: :y
  209. # @!method initialize(x:, y_:)
  210. # Some parameter documentations has been truncated, see
  211. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag::Path} for
  212. # more details.
  213. #
  214. # A series of x/y coordinate pairs in the drag path.
  215. #
  216. # @param x [Integer] The x-coordinate.
  217. #
  218. # @param y_ [Integer] The y-coordinate.
  219. end
  220. end
  221. 1 class Keypress < OpenAI::Internal::Type::BaseModel
  222. # @!attribute keys
  223. # The combination of keys the model is requesting to be pressed. This is an array
  224. # of strings, each representing a key.
  225. #
  226. # @return [Array<String>]
  227. 1 required :keys, OpenAI::Internal::Type::ArrayOf[String]
  228. # @!attribute type
  229. # Specifies the event type. For a keypress action, this property is always set to
  230. # `keypress`.
  231. #
  232. # @return [Symbol, :keypress]
  233. 1 required :type, const: :keypress
  234. # @!method initialize(keys:, type: :keypress)
  235. # Some parameter documentations has been truncated, see
  236. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress} for more
  237. # details.
  238. #
  239. # A collection of keypresses the model would like to perform.
  240. #
  241. # @param keys [Array<String>] The combination of keys the model is requesting to be pressed. This is an
  242. #
  243. # @param type [Symbol, :keypress] Specifies the event type. For a keypress action, this property is
  244. end
  245. 1 class Move < OpenAI::Internal::Type::BaseModel
  246. # @!attribute type
  247. # Specifies the event type. For a move action, this property is always set to
  248. # `move`.
  249. #
  250. # @return [Symbol, :move]
  251. 1 required :type, const: :move
  252. # @!attribute x
  253. # The x-coordinate to move to.
  254. #
  255. # @return [Integer]
  256. 1 required :x, Integer
  257. # @!attribute y_
  258. # The y-coordinate to move to.
  259. #
  260. # @return [Integer]
  261. 1 required :y_, Integer, api_name: :y
  262. # @!method initialize(x:, y_:, type: :move)
  263. # Some parameter documentations has been truncated, see
  264. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move} for more
  265. # details.
  266. #
  267. # A mouse move action.
  268. #
  269. # @param x [Integer] The x-coordinate to move to.
  270. #
  271. # @param y_ [Integer] The y-coordinate to move to.
  272. #
  273. # @param type [Symbol, :move] Specifies the event type. For a move action, this property is
  274. end
  275. 1 class Screenshot < OpenAI::Internal::Type::BaseModel
  276. # @!attribute type
  277. # Specifies the event type. For a screenshot action, this property is always set
  278. # to `screenshot`.
  279. #
  280. # @return [Symbol, :screenshot]
  281. 1 required :type, const: :screenshot
  282. # @!method initialize(type: :screenshot)
  283. # Some parameter documentations has been truncated, see
  284. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot} for
  285. # more details.
  286. #
  287. # A screenshot action.
  288. #
  289. # @param type [Symbol, :screenshot] Specifies the event type. For a screenshot action, this property is
  290. end
  291. 1 class Scroll < OpenAI::Internal::Type::BaseModel
  292. # @!attribute scroll_x
  293. # The horizontal scroll distance.
  294. #
  295. # @return [Integer]
  296. 1 required :scroll_x, Integer
  297. # @!attribute scroll_y
  298. # The vertical scroll distance.
  299. #
  300. # @return [Integer]
  301. 1 required :scroll_y, Integer
  302. # @!attribute type
  303. # Specifies the event type. For a scroll action, this property is always set to
  304. # `scroll`.
  305. #
  306. # @return [Symbol, :scroll]
  307. 1 required :type, const: :scroll
  308. # @!attribute x
  309. # The x-coordinate where the scroll occurred.
  310. #
  311. # @return [Integer]
  312. 1 required :x, Integer
  313. # @!attribute y_
  314. # The y-coordinate where the scroll occurred.
  315. #
  316. # @return [Integer]
  317. 1 required :y_, Integer, api_name: :y
  318. # @!method initialize(scroll_x:, scroll_y:, x:, y_:, type: :scroll)
  319. # Some parameter documentations has been truncated, see
  320. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll} for more
  321. # details.
  322. #
  323. # A scroll action.
  324. #
  325. # @param scroll_x [Integer] The horizontal scroll distance.
  326. #
  327. # @param scroll_y [Integer] The vertical scroll distance.
  328. #
  329. # @param x [Integer] The x-coordinate where the scroll occurred.
  330. #
  331. # @param y_ [Integer] The y-coordinate where the scroll occurred.
  332. #
  333. # @param type [Symbol, :scroll] Specifies the event type. For a scroll action, this property is
  334. end
  335. 1 class Type < OpenAI::Internal::Type::BaseModel
  336. # @!attribute text
  337. # The text to type.
  338. #
  339. # @return [String]
  340. 1 required :text, String
  341. # @!attribute type
  342. # Specifies the event type. For a type action, this property is always set to
  343. # `type`.
  344. #
  345. # @return [Symbol, :type]
  346. 1 required :type, const: :type
  347. # @!method initialize(text:, type: :type)
  348. # Some parameter documentations has been truncated, see
  349. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type} for more
  350. # details.
  351. #
  352. # An action to type in text.
  353. #
  354. # @param text [String] The text to type.
  355. #
  356. # @param type [Symbol, :type] Specifies the event type. For a type action, this property is
  357. end
  358. 1 class Wait < OpenAI::Internal::Type::BaseModel
  359. # @!attribute type
  360. # Specifies the event type. For a wait action, this property is always set to
  361. # `wait`.
  362. #
  363. # @return [Symbol, :wait]
  364. 1 required :type, const: :wait
  365. # @!method initialize(type: :wait)
  366. # Some parameter documentations has been truncated, see
  367. # {OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait} for more
  368. # details.
  369. #
  370. # A wait action.
  371. #
  372. # @param type [Symbol, :wait] Specifies the event type. For a wait action, this property is
  373. end
  374. # @!method self.variants
  375. # @return [Array(OpenAI::Models::Responses::ResponseComputerToolCall::Action::Click, OpenAI::Models::Responses::ResponseComputerToolCall::Action::DoubleClick, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Drag, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Keypress, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Move, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Screenshot, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Scroll, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Type, OpenAI::Models::Responses::ResponseComputerToolCall::Action::Wait)]
  376. end
  377. 1 class PendingSafetyCheck < OpenAI::Internal::Type::BaseModel
  378. # @!attribute id
  379. # The ID of the pending safety check.
  380. #
  381. # @return [String]
  382. 1 required :id, String
  383. # @!attribute code
  384. # The type of the pending safety check.
  385. #
  386. # @return [String]
  387. 1 required :code, String
  388. # @!attribute message
  389. # Details about the pending safety check.
  390. #
  391. # @return [String]
  392. 1 required :message, String
  393. # @!method initialize(id:, code:, message:)
  394. # A pending safety check for the computer call.
  395. #
  396. # @param id [String] The ID of the pending safety check.
  397. #
  398. # @param code [String] The type of the pending safety check.
  399. #
  400. # @param message [String] Details about the pending safety check.
  401. end
  402. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  403. # Populated when items are returned via API.
  404. #
  405. # @see OpenAI::Models::Responses::ResponseComputerToolCall#status
  406. 1 module Status
  407. 1 extend OpenAI::Internal::Type::Enum
  408. 1 IN_PROGRESS = :in_progress
  409. 1 COMPLETED = :completed
  410. 1 INCOMPLETE = :incomplete
  411. # @!method self.values
  412. # @return [Array<Symbol>]
  413. end
  414. # The type of the computer call. Always `computer_call`.
  415. #
  416. # @see OpenAI::Models::Responses::ResponseComputerToolCall#type
  417. 1 module Type
  418. 1 extend OpenAI::Internal::Type::Enum
  419. 1 COMPUTER_CALL = :computer_call
  420. # @!method self.values
  421. # @return [Array<Symbol>]
  422. end
  423. end
  424. end
  425. end
  426. end

openai-ruby/lib/openai/models/responses/response_computer_tool_call_output_item.rb

95.0% lines covered

100.0% branches covered

20 relevant lines. 19 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseComputerToolCallOutputItem < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the computer call tool output.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute call_id
  12. # The ID of the computer tool call that produced the output.
  13. #
  14. # @return [String]
  15. 1 required :call_id, String
  16. # @!attribute output
  17. # A computer screenshot image used with the computer use tool.
  18. #
  19. # @return [OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot]
  20. 1 required :output, -> { OpenAI::Responses::ResponseComputerToolCallOutputScreenshot }
  21. # @!attribute type
  22. # The type of the computer tool call output. Always `computer_call_output`.
  23. #
  24. # @return [Symbol, :computer_call_output]
  25. 1 required :type, const: :computer_call_output
  26. # @!attribute acknowledged_safety_checks
  27. # The safety checks reported by the API that have been acknowledged by the
  28. # developer.
  29. #
  30. # @return [Array<OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck>, nil]
  31. 1 optional :acknowledged_safety_checks,
  32. -> {
  33. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck]
  34. }
  35. # @!attribute status
  36. # The status of the message input. One of `in_progress`, `completed`, or
  37. # `incomplete`. Populated when input items are returned via API.
  38. #
  39. # @return [Symbol, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status, nil]
  40. 1 optional :status, enum: -> { OpenAI::Responses::ResponseComputerToolCallOutputItem::Status }
  41. # @!method initialize(id:, call_id:, output:, acknowledged_safety_checks: nil, status: nil, type: :computer_call_output)
  42. # Some parameter documentations has been truncated, see
  43. # {OpenAI::Models::Responses::ResponseComputerToolCallOutputItem} for more
  44. # details.
  45. #
  46. # @param id [String] The unique ID of the computer call tool output.
  47. #
  48. # @param call_id [String] The ID of the computer tool call that produced the output.
  49. #
  50. # @param output [OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot] A computer screenshot image used with the computer use tool.
  51. #
  52. # @param acknowledged_safety_checks [Array<OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::AcknowledgedSafetyCheck>] The safety checks reported by the API that have been acknowledged by the
  53. #
  54. # @param status [Symbol, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem::Status] The status of the message input. One of `in_progress`, `completed`, or
  55. #
  56. # @param type [Symbol, :computer_call_output] The type of the computer tool call output. Always `computer_call_output`.
  57. 1 class AcknowledgedSafetyCheck < OpenAI::Internal::Type::BaseModel
  58. # @!attribute id
  59. # The ID of the pending safety check.
  60. #
  61. # @return [String]
  62. 1 required :id, String
  63. # @!attribute code
  64. # The type of the pending safety check.
  65. #
  66. # @return [String]
  67. 1 required :code, String
  68. # @!attribute message
  69. # Details about the pending safety check.
  70. #
  71. # @return [String]
  72. 1 required :message, String
  73. # @!method initialize(id:, code:, message:)
  74. # A pending safety check for the computer call.
  75. #
  76. # @param id [String] The ID of the pending safety check.
  77. #
  78. # @param code [String] The type of the pending safety check.
  79. #
  80. # @param message [String] Details about the pending safety check.
  81. end
  82. # The status of the message input. One of `in_progress`, `completed`, or
  83. # `incomplete`. Populated when input items are returned via API.
  84. #
  85. # @see OpenAI::Models::Responses::ResponseComputerToolCallOutputItem#status
  86. 1 module Status
  87. 1 extend OpenAI::Internal::Type::Enum
  88. 1 IN_PROGRESS = :in_progress
  89. 1 COMPLETED = :completed
  90. 1 INCOMPLETE = :incomplete
  91. # @!method self.values
  92. # @return [Array<Symbol>]
  93. end
  94. end
  95. end
  96. end
  97. end

openai-ruby/lib/openai/models/responses/response_computer_tool_call_output_screenshot.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseComputerToolCallOutputScreenshot < OpenAI::Internal::Type::BaseModel
  6. # @!attribute type
  7. # Specifies the event type. For a computer screenshot, this property is always set
  8. # to `computer_screenshot`.
  9. #
  10. # @return [Symbol, :computer_screenshot]
  11. 1 required :type, const: :computer_screenshot
  12. # @!attribute file_id
  13. # The identifier of an uploaded file that contains the screenshot.
  14. #
  15. # @return [String, nil]
  16. 1 optional :file_id, String
  17. # @!attribute image_url
  18. # The URL of the screenshot image.
  19. #
  20. # @return [String, nil]
  21. 1 optional :image_url, String
  22. # @!method initialize(file_id: nil, image_url: nil, type: :computer_screenshot)
  23. # Some parameter documentations has been truncated, see
  24. # {OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot} for more
  25. # details.
  26. #
  27. # A computer screenshot image used with the computer use tool.
  28. #
  29. # @param file_id [String] The identifier of an uploaded file that contains the screenshot.
  30. #
  31. # @param image_url [String] The URL of the screenshot image.
  32. #
  33. # @param type [Symbol, :computer_screenshot] Specifies the event type. For a computer screenshot, this property is
  34. end
  35. end
  36. end
  37. end

openai-ruby/lib/openai/models/responses/response_content.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # Multi-modal input and output contents.
  6. 1 module ResponseContent
  7. 1 extend OpenAI::Internal::Type::Union
  8. # A text input to the model.
  9. 1 variant -> { OpenAI::Responses::ResponseInputText }
  10. # An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
  11. 1 variant -> { OpenAI::Responses::ResponseInputImage }
  12. # A file input to the model.
  13. 1 variant -> { OpenAI::Responses::ResponseInputFile }
  14. # A text output from the model.
  15. 1 variant -> { OpenAI::Responses::ResponseOutputText }
  16. # A refusal from the model.
  17. 1 variant -> { OpenAI::Responses::ResponseOutputRefusal }
  18. # @!method self.variants
  19. # @return [Array(OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile, OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)]
  20. end
  21. end
  22. end
  23. end

openai-ruby/lib/openai/models/responses/response_content_part_added_event.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseContentPartAddedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content_index
  7. # The index of the content part that was added.
  8. #
  9. # @return [Integer]
  10. 1 required :content_index, Integer
  11. # @!attribute item_id
  12. # The ID of the output item that the content part was added to.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute output_index
  17. # The index of the output item that the content part was added to.
  18. #
  19. # @return [Integer]
  20. 1 required :output_index, Integer
  21. # @!attribute part
  22. # The content part that was added.
  23. #
  24. # @return [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal]
  25. 1 required :part, union: -> { OpenAI::Responses::ResponseContentPartAddedEvent::Part }
  26. # @!attribute sequence_number
  27. # The sequence number of this event.
  28. #
  29. # @return [Integer]
  30. 1 required :sequence_number, Integer
  31. # @!attribute type
  32. # The type of the event. Always `response.content_part.added`.
  33. #
  34. # @return [Symbol, :"response.content_part.added"]
  35. 1 required :type, const: :"response.content_part.added"
  36. # @!method initialize(content_index:, item_id:, output_index:, part:, sequence_number:, type: :"response.content_part.added")
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseContentPartAddedEvent} for more details.
  39. #
  40. # Emitted when a new content part is added.
  41. #
  42. # @param content_index [Integer] The index of the content part that was added.
  43. #
  44. # @param item_id [String] The ID of the output item that the content part was added to.
  45. #
  46. # @param output_index [Integer] The index of the output item that the content part was added to.
  47. #
  48. # @param part [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] The content part that was added.
  49. #
  50. # @param sequence_number [Integer] The sequence number of this event.
  51. #
  52. # @param type [Symbol, :"response.content_part.added"] The type of the event. Always `response.content_part.added`.
  53. # The content part that was added.
  54. #
  55. # @see OpenAI::Models::Responses::ResponseContentPartAddedEvent#part
  56. 1 module Part
  57. 1 extend OpenAI::Internal::Type::Union
  58. 1 discriminator :type
  59. # A text output from the model.
  60. 1 variant :output_text, -> { OpenAI::Responses::ResponseOutputText }
  61. # A refusal from the model.
  62. 1 variant :refusal, -> { OpenAI::Responses::ResponseOutputRefusal }
  63. # @!method self.variants
  64. # @return [Array(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)]
  65. end
  66. end
  67. end
  68. end
  69. end

openai-ruby/lib/openai/models/responses/response_content_part_done_event.rb

100.0% lines covered

100.0% branches covered

15 relevant lines. 15 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseContentPartDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content_index
  7. # The index of the content part that is done.
  8. #
  9. # @return [Integer]
  10. 1 required :content_index, Integer
  11. # @!attribute item_id
  12. # The ID of the output item that the content part was added to.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute output_index
  17. # The index of the output item that the content part was added to.
  18. #
  19. # @return [Integer]
  20. 1 required :output_index, Integer
  21. # @!attribute part
  22. # The content part that is done.
  23. #
  24. # @return [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal]
  25. 1 required :part, union: -> { OpenAI::Responses::ResponseContentPartDoneEvent::Part }
  26. # @!attribute sequence_number
  27. # The sequence number of this event.
  28. #
  29. # @return [Integer]
  30. 1 required :sequence_number, Integer
  31. # @!attribute type
  32. # The type of the event. Always `response.content_part.done`.
  33. #
  34. # @return [Symbol, :"response.content_part.done"]
  35. 1 required :type, const: :"response.content_part.done"
  36. # @!method initialize(content_index:, item_id:, output_index:, part:, sequence_number:, type: :"response.content_part.done")
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseContentPartDoneEvent} for more details.
  39. #
  40. # Emitted when a content part is done.
  41. #
  42. # @param content_index [Integer] The index of the content part that is done.
  43. #
  44. # @param item_id [String] The ID of the output item that the content part was added to.
  45. #
  46. # @param output_index [Integer] The index of the output item that the content part was added to.
  47. #
  48. # @param part [OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal] The content part that is done.
  49. #
  50. # @param sequence_number [Integer] The sequence number of this event.
  51. #
  52. # @param type [Symbol, :"response.content_part.done"] The type of the event. Always `response.content_part.done`.
  53. # The content part that is done.
  54. #
  55. # @see OpenAI::Models::Responses::ResponseContentPartDoneEvent#part
  56. 1 module Part
  57. 1 extend OpenAI::Internal::Type::Union
  58. 1 discriminator :type
  59. # A text output from the model.
  60. 1 variant :output_text, -> { OpenAI::Responses::ResponseOutputText }
  61. # A refusal from the model.
  62. 1 variant :refusal, -> { OpenAI::Responses::ResponseOutputRefusal }
  63. # @!method self.variants
  64. # @return [Array(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)]
  65. end
  66. end
  67. end
  68. end
  69. end

openai-ruby/lib/openai/models/responses/response_create_params.rb

98.11% lines covered

100.0% branches covered

53 relevant lines. 52 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # @see OpenAI::Resources::Responses#create
  6. #
  7. # @see OpenAI::Resources::Responses#stream_raw
  8. 1 class ResponseCreateParams < OpenAI::Internal::Type::BaseModel
  9. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  10. 1 include OpenAI::Internal::Type::RequestParameters
  11. # @!attribute background
  12. # Whether to run the model response in the background.
  13. # [Learn more](https://platform.openai.com/docs/guides/background).
  14. #
  15. # @return [Boolean, nil]
  16. 1 optional :background, OpenAI::Internal::Type::Boolean, nil?: true
  17. # @!attribute include
  18. # Specify additional output data to include in the model response. Currently
  19. # supported values are:
  20. #
  21. # - `code_interpreter_call.outputs`: Includes the outputs of python code execution
  22. # in code interpreter tool call items.
  23. # - `computer_call_output.output.image_url`: Include image urls from the computer
  24. # call output.
  25. # - `file_search_call.results`: Include the search results of the file search tool
  26. # call.
  27. # - `message.input_image.image_url`: Include image urls from the input message.
  28. # - `message.output_text.logprobs`: Include logprobs with assistant messages.
  29. # - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
  30. # tokens in reasoning item outputs. This enables reasoning items to be used in
  31. # multi-turn conversations when using the Responses API statelessly (like when
  32. # the `store` parameter is set to `false`, or when an organization is enrolled
  33. # in the zero data retention program).
  34. #
  35. # @return [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>, nil]
  36. 1 optional :include,
  37. -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Responses::ResponseIncludable] },
  38. nil?: true
  39. # @!attribute input
  40. # Text, image, or file inputs to the model, used to generate a response.
  41. #
  42. # Learn more:
  43. #
  44. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  45. # - [Image inputs](https://platform.openai.com/docs/guides/images)
  46. # - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
  47. # - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
  48. # - [Function calling](https://platform.openai.com/docs/guides/function-calling)
  49. #
  50. # @return [String, Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference>, nil]
  51. 3 optional :input, union: -> { OpenAI::Responses::ResponseCreateParams::Input }
  52. # @!attribute instructions
  53. # A system (or developer) message inserted into the model's context.
  54. #
  55. # When using along with `previous_response_id`, the instructions from a previous
  56. # response will not be carried over to the next response. This makes it simple to
  57. # swap out system (or developer) messages in new responses.
  58. #
  59. # @return [String, nil]
  60. 1 optional :instructions, String, nil?: true
  61. # @!attribute max_output_tokens
  62. # An upper bound for the number of tokens that can be generated for a response,
  63. # including visible output tokens and
  64. # [reasoning tokens](https://platform.openai.com/docs/guides/reasoning).
  65. #
  66. # @return [Integer, nil]
  67. 1 optional :max_output_tokens, Integer, nil?: true
  68. # @!attribute max_tool_calls
  69. # The maximum number of total calls to built-in tools that can be processed in a
  70. # response. This maximum number applies across all built-in tool calls, not per
  71. # individual tool. Any further attempts to call a tool by the model will be
  72. # ignored.
  73. #
  74. # @return [Integer, nil]
  75. 1 optional :max_tool_calls, Integer, nil?: true
  76. # @!attribute metadata
  77. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  78. # for storing additional information about the object in a structured format, and
  79. # querying for objects via API or the dashboard.
  80. #
  81. # Keys are strings with a maximum length of 64 characters. Values are strings with
  82. # a maximum length of 512 characters.
  83. #
  84. # @return [Hash{Symbol=>String}, nil]
  85. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  86. # @!attribute model
  87. # Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI offers a
  88. # wide range of models with different capabilities, performance characteristics,
  89. # and price points. Refer to the
  90. # [model guide](https://platform.openai.com/docs/models) to browse and compare
  91. # available models.
  92. #
  93. # @return [String, Symbol, OpenAI::Models::ChatModel, OpenAI::Models::ResponsesModel::ResponsesOnlyModel, nil]
  94. 3 optional :model, union: -> { OpenAI::ResponsesModel }
  95. # @!attribute parallel_tool_calls
  96. # Whether to allow the model to run tool calls in parallel.
  97. #
  98. # @return [Boolean, nil]
  99. 1 optional :parallel_tool_calls, OpenAI::Internal::Type::Boolean, nil?: true
  100. # @!attribute previous_response_id
  101. # The unique ID of the previous response to the model. Use this to create
  102. # multi-turn conversations. Learn more about
  103. # [conversation state](https://platform.openai.com/docs/guides/conversation-state).
  104. #
  105. # @return [String, nil]
  106. 1 optional :previous_response_id, String, nil?: true
  107. # @!attribute prompt
  108. # Reference to a prompt template and its variables.
  109. # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
  110. #
  111. # @return [OpenAI::Models::Responses::ResponsePrompt, nil]
  112. 1 optional :prompt, -> { OpenAI::Responses::ResponsePrompt }, nil?: true
  113. # @!attribute prompt_cache_key
  114. # Used by OpenAI to cache responses for similar requests to optimize your cache
  115. # hit rates. Replaces the `user` field.
  116. # [Learn more](https://platform.openai.com/docs/guides/prompt-caching).
  117. #
  118. # @return [String, nil]
  119. 1 optional :prompt_cache_key, String
  120. # @!attribute reasoning
  121. # **o-series models only**
  122. #
  123. # Configuration options for
  124. # [reasoning models](https://platform.openai.com/docs/guides/reasoning).
  125. #
  126. # @return [OpenAI::Models::Reasoning, nil]
  127. 1 optional :reasoning, -> { OpenAI::Reasoning }, nil?: true
  128. # @!attribute safety_identifier
  129. # A stable identifier used to help detect users of your application that may be
  130. # violating OpenAI's usage policies. The IDs should be a string that uniquely
  131. # identifies each user. We recommend hashing their username or email address, in
  132. # order to avoid sending us any identifying information.
  133. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
  134. #
  135. # @return [String, nil]
  136. 1 optional :safety_identifier, String
  137. # @!attribute service_tier
  138. # Specifies the processing type used for serving the request.
  139. #
  140. # - If set to 'auto', then the request will be processed with the service tier
  141. # configured in the Project settings. Unless otherwise configured, the Project
  142. # will use 'default'.
  143. # - If set to 'default', then the request will be processed with the standard
  144. # pricing and performance for the selected model.
  145. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  146. # 'priority', then the request will be processed with the corresponding service
  147. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  148. # Priority processing.
  149. # - When not set, the default behavior is 'auto'.
  150. #
  151. # When the `service_tier` parameter is set, the response body will include the
  152. # `service_tier` value based on the processing mode actually used to serve the
  153. # request. This response value may be different from the value set in the
  154. # parameter.
  155. #
  156. # @return [Symbol, OpenAI::Models::Responses::ResponseCreateParams::ServiceTier, nil]
  157. 1 optional :service_tier, enum: -> { OpenAI::Responses::ResponseCreateParams::ServiceTier }, nil?: true
  158. # @!attribute store
  159. # Whether to store the generated model response for later retrieval via API.
  160. #
  161. # @return [Boolean, nil]
  162. 1 optional :store, OpenAI::Internal::Type::Boolean, nil?: true
  163. # @!attribute temperature
  164. # What sampling temperature to use, between 0 and 2. Higher values like 0.8 will
  165. # make the output more random, while lower values like 0.2 will make it more
  166. # focused and deterministic. We generally recommend altering this or `top_p` but
  167. # not both.
  168. #
  169. # @return [Float, nil]
  170. 1 optional :temperature, Float, nil?: true
  171. # @!attribute text
  172. # Configuration options for a text response from the model. Can be plain text or
  173. # structured JSON data. Learn more:
  174. #
  175. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  176. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  177. #
  178. # @return [OpenAI::Models::Responses::ResponseTextConfig, nil]
  179. 1 optional :text,
  180. union: -> {
  181. 2 OpenAI::UnionOf[
  182. OpenAI::Responses::ResponseTextConfig,
  183. OpenAI::StructuredOutput::JsonSchemaConverter
  184. ]
  185. }
  186. # @!attribute tool_choice
  187. # How the model should select which tool (or tools) to use when generating a
  188. # response. See the `tools` parameter to see how to specify which tools the model
  189. # can call.
  190. #
  191. # @return [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp, nil]
  192. 1 optional :tool_choice, union: -> { OpenAI::Responses::ResponseCreateParams::ToolChoice }
  193. # @!attribute tools
  194. # An array of tools the model may call while generating a response. You can
  195. # specify which tool to use by setting the `tool_choice` parameter.
  196. #
  197. # The two categories of tools you can provide the model are:
  198. #
  199. # - **Built-in tools**: Tools that are provided by OpenAI that extend the model's
  200. # capabilities, like
  201. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  202. # [file search](https://platform.openai.com/docs/guides/tools-file-search).
  203. # Learn more about
  204. # [built-in tools](https://platform.openai.com/docs/guides/tools).
  205. # - **Function calls (custom tools)**: Functions that are defined by you, enabling
  206. # the model to call your own code. Learn more about
  207. # [function calling](https://platform.openai.com/docs/guides/function-calling).
  208. #
  209. # @return [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::StructuredOutput::JsonSchemaConverter, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>, nil]
  210. 1 optional :tools, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::Tool] }
  211. # @!attribute top_logprobs
  212. # An integer between 0 and 20 specifying the number of most likely tokens to
  213. # return at each token position, each with an associated log probability.
  214. #
  215. # @return [Integer, nil]
  216. 1 optional :top_logprobs, Integer, nil?: true
  217. # @!attribute top_p
  218. # An alternative to sampling with temperature, called nucleus sampling, where the
  219. # model considers the results of the tokens with top_p probability mass. So 0.1
  220. # means only the tokens comprising the top 10% probability mass are considered.
  221. #
  222. # We generally recommend altering this or `temperature` but not both.
  223. #
  224. # @return [Float, nil]
  225. 1 optional :top_p, Float, nil?: true
  226. # @!attribute truncation
  227. # The truncation strategy to use for the model response.
  228. #
  229. # - `auto`: If the context of this response and previous ones exceeds the model's
  230. # context window size, the model will truncate the response to fit the context
  231. # window by dropping input items in the middle of the conversation.
  232. # - `disabled` (default): If a model response will exceed the context window size
  233. # for a model, the request will fail with a 400 error.
  234. #
  235. # @return [Symbol, OpenAI::Models::Responses::ResponseCreateParams::Truncation, nil]
  236. 1 optional :truncation, enum: -> { OpenAI::Responses::ResponseCreateParams::Truncation }, nil?: true
  237. # @!attribute user
  238. # @deprecated
  239. #
  240. # This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  241. # `prompt_cache_key` instead to maintain caching optimizations. A stable
  242. # identifier for your end-users. Used to boost cache hit rates by better bucketing
  243. # similar requests and to help OpenAI detect and prevent abuse.
  244. # [Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
  245. #
  246. # @return [String, nil]
  247. 1 optional :user, String
  248. # @!method initialize(background: nil, include: nil, input: nil, instructions: nil, max_output_tokens: nil, max_tool_calls: nil, metadata: nil, model: nil, parallel_tool_calls: nil, previous_response_id: nil, prompt: nil, prompt_cache_key: nil, reasoning: nil, safety_identifier: nil, service_tier: nil, store: nil, temperature: nil, text: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, truncation: nil, user: nil, request_options: {})
  249. # Some parameter documentations has been truncated, see
  250. # {OpenAI::Models::Responses::ResponseCreateParams} for more details.
  251. #
  252. # @param background [Boolean, nil] Whether to run the model response in the background.
  253. #
  254. # @param include [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>, nil] Specify additional output data to include in the model response. Currently
  255. #
  256. # @param input [String, Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference>] Text, image, or file inputs to the model, used to generate a response.
  257. #
  258. # @param instructions [String, nil] A system (or developer) message inserted into the model's context.
  259. #
  260. # @param max_output_tokens [Integer, nil] An upper bound for the number of tokens that can be generated for a response, in
  261. #
  262. # @param max_tool_calls [Integer, nil] The maximum number of total calls to built-in tools that can be processed in a r
  263. #
  264. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  265. #
  266. # @param model [String, Symbol, OpenAI::Models::ChatModel, OpenAI::Models::ResponsesModel::ResponsesOnlyModel] Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
  267. #
  268. # @param parallel_tool_calls [Boolean, nil] Whether to allow the model to run tool calls in parallel.
  269. #
  270. # @param previous_response_id [String, nil] The unique ID of the previous response to the model. Use this to
  271. #
  272. # @param prompt [OpenAI::Models::Responses::ResponsePrompt, nil] Reference to a prompt template and its variables.
  273. #
  274. # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi
  275. #
  276. # @param reasoning [OpenAI::Models::Reasoning, nil] **o-series models only**
  277. #
  278. # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi
  279. #
  280. # @param service_tier [Symbol, OpenAI::Models::Responses::ResponseCreateParams::ServiceTier, nil] Specifies the processing type used for serving the request.
  281. #
  282. # @param store [Boolean, nil] Whether to store the generated model response for later retrieval via
  283. #
  284. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  285. #
  286. # @param text [OpenAI::Models::Responses::ResponseTextConfig] Configuration options for a text response from the model. Can be plain
  287. #
  288. # @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp] How the model should select which tool (or tools) to use when generating
  289. #
  290. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::StructuredOutput::JsonSchemaConverter, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  291. #
  292. # @param top_logprobs [Integer, nil] An integer between 0 and 20 specifying the number of most likely tokens to
  293. #
  294. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling,
  295. #
  296. # @param truncation [Symbol, OpenAI::Models::Responses::ResponseCreateParams::Truncation, nil] The truncation strategy to use for the model response.
  297. #
  298. # @param user [String] This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  299. #
  300. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  301. # Text, image, or file inputs to the model, used to generate a response.
  302. #
  303. # Learn more:
  304. #
  305. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  306. # - [Image inputs](https://platform.openai.com/docs/guides/images)
  307. # - [File inputs](https://platform.openai.com/docs/guides/pdf-files)
  308. # - [Conversation state](https://platform.openai.com/docs/guides/conversation-state)
  309. # - [Function calling](https://platform.openai.com/docs/guides/function-calling)
  310. 1 module Input
  311. 1 extend OpenAI::Internal::Type::Union
  312. # A text input to the model, equivalent to a text input with the
  313. # `user` role.
  314. 1 variant String
  315. # A list of one or many input items to the model, containing
  316. # different content types.
  317. 3 variant -> { OpenAI::Responses::ResponseInput }
  318. # @!method self.variants
  319. # @return [Array(String, Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference>)]
  320. end
  321. # Specifies the processing type used for serving the request.
  322. #
  323. # - If set to 'auto', then the request will be processed with the service tier
  324. # configured in the Project settings. Unless otherwise configured, the Project
  325. # will use 'default'.
  326. # - If set to 'default', then the request will be processed with the standard
  327. # pricing and performance for the selected model.
  328. # - If set to '[flex](https://platform.openai.com/docs/guides/flex-processing)' or
  329. # 'priority', then the request will be processed with the corresponding service
  330. # tier. [Contact sales](https://openai.com/contact-sales) to learn more about
  331. # Priority processing.
  332. # - When not set, the default behavior is 'auto'.
  333. #
  334. # When the `service_tier` parameter is set, the response body will include the
  335. # `service_tier` value based on the processing mode actually used to serve the
  336. # request. This response value may be different from the value set in the
  337. # parameter.
  338. 1 module ServiceTier
  339. 1 extend OpenAI::Internal::Type::Enum
  340. 1 AUTO = :auto
  341. 1 DEFAULT = :default
  342. 1 FLEX = :flex
  343. 1 SCALE = :scale
  344. 1 PRIORITY = :priority
  345. # @!method self.values
  346. # @return [Array<Symbol>]
  347. end
  348. # How the model should select which tool (or tools) to use when generating a
  349. # response. See the `tools` parameter to see how to specify which tools the model
  350. # can call.
  351. 1 module ToolChoice
  352. 1 extend OpenAI::Internal::Type::Union
  353. # Controls which (if any) tool is called by the model.
  354. #
  355. # `none` means the model will not call any tool and instead generates a message.
  356. #
  357. # `auto` means the model can pick between generating a message or calling one or
  358. # more tools.
  359. #
  360. # `required` means the model must call one or more tools.
  361. 1 variant enum: -> { OpenAI::Responses::ToolChoiceOptions }
  362. # Indicates that the model should use a built-in tool to generate a response.
  363. # [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
  364. 1 variant -> { OpenAI::Responses::ToolChoiceTypes }
  365. # Use this option to force the model to call a specific function.
  366. 1 variant -> { OpenAI::Responses::ToolChoiceFunction }
  367. # Use this option to force the model to call a specific tool on a remote MCP server.
  368. 1 variant -> { OpenAI::Responses::ToolChoiceMcp }
  369. # @!method self.variants
  370. # @return [Array(Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp)]
  371. end
  372. # The truncation strategy to use for the model response.
  373. #
  374. # - `auto`: If the context of this response and previous ones exceeds the model's
  375. # context window size, the model will truncate the response to fit the context
  376. # window by dropping input items in the middle of the conversation.
  377. # - `disabled` (default): If a model response will exceed the context window size
  378. # for a model, the request will fail with a 400 error.
  379. 1 module Truncation
  380. 1 extend OpenAI::Internal::Type::Enum
  381. 1 AUTO = :auto
  382. 1 DISABLED = :disabled
  383. # @!method self.values
  384. # @return [Array<Symbol>]
  385. end
  386. end
  387. end
  388. end
  389. end

openai-ruby/lib/openai/models/responses/response_created_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseCreatedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute response
  7. # The response that was created.
  8. #
  9. # @return [OpenAI::Models::Responses::Response]
  10. 1 required :response, -> { OpenAI::Responses::Response }
  11. # @!attribute sequence_number
  12. # The sequence number for this event.
  13. #
  14. # @return [Integer]
  15. 1 required :sequence_number, Integer
  16. # @!attribute type
  17. # The type of the event. Always `response.created`.
  18. #
  19. # @return [Symbol, :"response.created"]
  20. 1 required :type, const: :"response.created"
  21. # @!method initialize(response:, sequence_number:, type: :"response.created")
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ResponseCreatedEvent} for more details.
  24. #
  25. # An event that is emitted when a response is created.
  26. #
  27. # @param response [OpenAI::Models::Responses::Response] The response that was created.
  28. #
  29. # @param sequence_number [Integer] The sequence number for this event.
  30. #
  31. # @param type [Symbol, :"response.created"] The type of the event. Always `response.created`.
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/responses/response_delete_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # @see OpenAI::Resources::Responses#delete
  6. 1 class ResponseDeleteParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/models/responses/response_error.rb

100.0% lines covered

100.0% branches covered

26 relevant lines. 26 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseError < OpenAI::Internal::Type::BaseModel
  6. # @!attribute code
  7. # The error code for the response.
  8. #
  9. # @return [Symbol, OpenAI::Models::Responses::ResponseError::Code]
  10. 1 required :code, enum: -> { OpenAI::Responses::ResponseError::Code }
  11. # @!attribute message
  12. # A human-readable description of the error.
  13. #
  14. # @return [String]
  15. 1 required :message, String
  16. # @!method initialize(code:, message:)
  17. # Some parameter documentations has been truncated, see
  18. # {OpenAI::Models::Responses::ResponseError} for more details.
  19. #
  20. # An error object returned when the model fails to generate a Response.
  21. #
  22. # @param code [Symbol, OpenAI::Models::Responses::ResponseError::Code] The error code for the response.
  23. #
  24. # @param message [String] A human-readable description of the error.
  25. # The error code for the response.
  26. #
  27. # @see OpenAI::Models::Responses::ResponseError#code
  28. 1 module Code
  29. 1 extend OpenAI::Internal::Type::Enum
  30. 1 SERVER_ERROR = :server_error
  31. 1 RATE_LIMIT_EXCEEDED = :rate_limit_exceeded
  32. 1 INVALID_PROMPT = :invalid_prompt
  33. 1 VECTOR_STORE_TIMEOUT = :vector_store_timeout
  34. 1 INVALID_IMAGE = :invalid_image
  35. 1 INVALID_IMAGE_FORMAT = :invalid_image_format
  36. 1 INVALID_BASE64_IMAGE = :invalid_base64_image
  37. 1 INVALID_IMAGE_URL = :invalid_image_url
  38. 1 IMAGE_TOO_LARGE = :image_too_large
  39. 1 IMAGE_TOO_SMALL = :image_too_small
  40. 1 IMAGE_PARSE_ERROR = :image_parse_error
  41. 1 IMAGE_CONTENT_POLICY_VIOLATION = :image_content_policy_violation
  42. 1 INVALID_IMAGE_MODE = :invalid_image_mode
  43. 1 IMAGE_FILE_TOO_LARGE = :image_file_too_large
  44. 1 UNSUPPORTED_IMAGE_MEDIA_TYPE = :unsupported_image_media_type
  45. 1 EMPTY_IMAGE_FILE = :empty_image_file
  46. 1 FAILED_TO_DOWNLOAD_IMAGE = :failed_to_download_image
  47. 1 IMAGE_FILE_NOT_FOUND = :image_file_not_found
  48. # @!method self.values
  49. # @return [Array<Symbol>]
  50. end
  51. end
  52. end
  53. end
  54. end

openai-ruby/lib/openai/models/responses/response_error_event.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseErrorEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute code
  7. # The error code.
  8. #
  9. # @return [String, nil]
  10. 1 required :code, String, nil?: true
  11. # @!attribute message
  12. # The error message.
  13. #
  14. # @return [String]
  15. 1 required :message, String
  16. # @!attribute param
  17. # The error parameter.
  18. #
  19. # @return [String, nil]
  20. 1 required :param, String, nil?: true
  21. # @!attribute sequence_number
  22. # The sequence number of this event.
  23. #
  24. # @return [Integer]
  25. 1 required :sequence_number, Integer
  26. # @!attribute type
  27. # The type of the event. Always `error`.
  28. #
  29. # @return [Symbol, :error]
  30. 1 required :type, const: :error
  31. # @!method initialize(code:, message:, param:, sequence_number:, type: :error)
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Responses::ResponseErrorEvent} for more details.
  34. #
  35. # Emitted when an error occurs.
  36. #
  37. # @param code [String, nil] The error code.
  38. #
  39. # @param message [String] The error message.
  40. #
  41. # @param param [String, nil] The error parameter.
  42. #
  43. # @param sequence_number [Integer] The sequence number of this event.
  44. #
  45. # @param type [Symbol, :error] The type of the event. Always `error`.
  46. end
  47. end
  48. end
  49. end

openai-ruby/lib/openai/models/responses/response_failed_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFailedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute response
  7. # The response that failed.
  8. #
  9. # @return [OpenAI::Models::Responses::Response]
  10. 1 required :response, -> { OpenAI::Responses::Response }
  11. # @!attribute sequence_number
  12. # The sequence number of this event.
  13. #
  14. # @return [Integer]
  15. 1 required :sequence_number, Integer
  16. # @!attribute type
  17. # The type of the event. Always `response.failed`.
  18. #
  19. # @return [Symbol, :"response.failed"]
  20. 1 required :type, const: :"response.failed"
  21. # @!method initialize(response:, sequence_number:, type: :"response.failed")
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ResponseFailedEvent} for more details.
  24. #
  25. # An event that is emitted when a response fails.
  26. #
  27. # @param response [OpenAI::Models::Responses::Response] The response that failed.
  28. #
  29. # @param sequence_number [Integer] The sequence number of this event.
  30. #
  31. # @param type [Symbol, :"response.failed"] The type of the event. Always `response.failed`.
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/responses/response_file_search_call_completed_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFileSearchCallCompletedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the output item that the file search call is initiated.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that the file search call is initiated.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always `response.file_search_call.completed`.
  23. #
  24. # @return [Symbol, :"response.file_search_call.completed"]
  25. 1 required :type, const: :"response.file_search_call.completed"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.file_search_call.completed")
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent} for more
  29. # details.
  30. #
  31. # Emitted when a file search call is completed (results found).
  32. #
  33. # @param item_id [String] The ID of the output item that the file search call is initiated.
  34. #
  35. # @param output_index [Integer] The index of the output item that the file search call is initiated.
  36. #
  37. # @param sequence_number [Integer] The sequence number of this event.
  38. #
  39. # @param type [Symbol, :"response.file_search_call.completed"] The type of the event. Always `response.file_search_call.completed`.
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/responses/response_file_search_call_in_progress_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFileSearchCallInProgressEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the output item that the file search call is initiated.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that the file search call is initiated.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always `response.file_search_call.in_progress`.
  23. #
  24. # @return [Symbol, :"response.file_search_call.in_progress"]
  25. 1 required :type, const: :"response.file_search_call.in_progress"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.file_search_call.in_progress")
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent} for more
  29. # details.
  30. #
  31. # Emitted when a file search call is initiated.
  32. #
  33. # @param item_id [String] The ID of the output item that the file search call is initiated.
  34. #
  35. # @param output_index [Integer] The index of the output item that the file search call is initiated.
  36. #
  37. # @param sequence_number [Integer] The sequence number of this event.
  38. #
  39. # @param type [Symbol, :"response.file_search_call.in_progress"] The type of the event. Always `response.file_search_call.in_progress`.
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/responses/response_file_search_call_searching_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFileSearchCallSearchingEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the output item that the file search call is initiated.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that the file search call is searching.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always `response.file_search_call.searching`.
  23. #
  24. # @return [Symbol, :"response.file_search_call.searching"]
  25. 1 required :type, const: :"response.file_search_call.searching"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.file_search_call.searching")
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent} for more
  29. # details.
  30. #
  31. # Emitted when a file search is currently searching.
  32. #
  33. # @param item_id [String] The ID of the output item that the file search call is initiated.
  34. #
  35. # @param output_index [Integer] The index of the output item that the file search call is searching.
  36. #
  37. # @param sequence_number [Integer] The sequence number of this event.
  38. #
  39. # @param type [Symbol, :"response.file_search_call.searching"] The type of the event. Always `response.file_search_call.searching`.
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/responses/response_file_search_tool_call.rb

93.1% lines covered

100.0% branches covered

29 relevant lines. 27 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFileSearchToolCall < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the file search tool call.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute queries
  12. # The queries used to search for files.
  13. #
  14. # @return [Array<String>]
  15. 1 required :queries, OpenAI::Internal::Type::ArrayOf[String]
  16. # @!attribute status
  17. # The status of the file search tool call. One of `in_progress`, `searching`,
  18. # `incomplete` or `failed`,
  19. #
  20. # @return [Symbol, OpenAI::Models::Responses::ResponseFileSearchToolCall::Status]
  21. 1 required :status, enum: -> { OpenAI::Responses::ResponseFileSearchToolCall::Status }
  22. # @!attribute type
  23. # The type of the file search tool call. Always `file_search_call`.
  24. #
  25. # @return [Symbol, :file_search_call]
  26. 1 required :type, const: :file_search_call
  27. # @!attribute results
  28. # The results of the file search tool call.
  29. #
  30. # @return [Array<OpenAI::Models::Responses::ResponseFileSearchToolCall::Result>, nil]
  31. 1 optional :results,
  32. -> {
  33. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseFileSearchToolCall::Result]
  34. },
  35. nil?: true
  36. # @!method initialize(id:, queries:, status:, results: nil, type: :file_search_call)
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseFileSearchToolCall} for more details.
  39. #
  40. # The results of a file search tool call. See the
  41. # [file search guide](https://platform.openai.com/docs/guides/tools-file-search)
  42. # for more information.
  43. #
  44. # @param id [String] The unique ID of the file search tool call.
  45. #
  46. # @param queries [Array<String>] The queries used to search for files.
  47. #
  48. # @param status [Symbol, OpenAI::Models::Responses::ResponseFileSearchToolCall::Status] The status of the file search tool call. One of `in_progress`,
  49. #
  50. # @param results [Array<OpenAI::Models::Responses::ResponseFileSearchToolCall::Result>, nil] The results of the file search tool call.
  51. #
  52. # @param type [Symbol, :file_search_call] The type of the file search tool call. Always `file_search_call`.
  53. # The status of the file search tool call. One of `in_progress`, `searching`,
  54. # `incomplete` or `failed`,
  55. #
  56. # @see OpenAI::Models::Responses::ResponseFileSearchToolCall#status
  57. 1 module Status
  58. 1 extend OpenAI::Internal::Type::Enum
  59. 1 IN_PROGRESS = :in_progress
  60. 1 SEARCHING = :searching
  61. 1 COMPLETED = :completed
  62. 1 INCOMPLETE = :incomplete
  63. 1 FAILED = :failed
  64. # @!method self.values
  65. # @return [Array<Symbol>]
  66. end
  67. 1 class Result < OpenAI::Internal::Type::BaseModel
  68. # @!attribute attributes
  69. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  70. # for storing additional information about the object in a structured format, and
  71. # querying for objects via API or the dashboard. Keys are strings with a maximum
  72. # length of 64 characters. Values are strings with a maximum length of 512
  73. # characters, booleans, or numbers.
  74. #
  75. # @return [Hash{Symbol=>String, Float, Boolean}, nil]
  76. 1 optional :attributes,
  77. -> {
  78. OpenAI::Internal::Type::HashOf[union: OpenAI::Responses::ResponseFileSearchToolCall::Result::Attribute]
  79. },
  80. nil?: true
  81. # @!attribute file_id
  82. # The unique ID of the file.
  83. #
  84. # @return [String, nil]
  85. 1 optional :file_id, String
  86. # @!attribute filename
  87. # The name of the file.
  88. #
  89. # @return [String, nil]
  90. 1 optional :filename, String
  91. # @!attribute score
  92. # The relevance score of the file - a value between 0 and 1.
  93. #
  94. # @return [Float, nil]
  95. 1 optional :score, Float
  96. # @!attribute text
  97. # The text that was retrieved from the file.
  98. #
  99. # @return [String, nil]
  100. 1 optional :text, String
  101. # @!method initialize(attributes: nil, file_id: nil, filename: nil, score: nil, text: nil)
  102. # Some parameter documentations has been truncated, see
  103. # {OpenAI::Models::Responses::ResponseFileSearchToolCall::Result} for more
  104. # details.
  105. #
  106. # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  107. #
  108. # @param file_id [String] The unique ID of the file.
  109. #
  110. # @param filename [String] The name of the file.
  111. #
  112. # @param score [Float] The relevance score of the file - a value between 0 and 1.
  113. #
  114. # @param text [String] The text that was retrieved from the file.
  115. 1 module Attribute
  116. 1 extend OpenAI::Internal::Type::Union
  117. 1 variant String
  118. 1 variant Float
  119. 1 variant OpenAI::Internal::Type::Boolean
  120. # @!method self.variants
  121. # @return [Array(String, Float, Boolean)]
  122. end
  123. end
  124. end
  125. end
  126. end
  127. end

openai-ruby/lib/openai/models/responses/response_format_text_config.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # An object specifying the format that the model must output.
  6. #
  7. # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
  8. # ensures the model will match your supplied JSON schema. Learn more in the
  9. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  10. #
  11. # The default format is `{ "type": "text" }` with no additional options.
  12. #
  13. # **Not recommended for gpt-4o and newer models:**
  14. #
  15. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  16. # ensures the message the model generates is valid JSON. Using `json_schema` is
  17. # preferred for models that support it.
  18. 1 module ResponseFormatTextConfig
  19. 1 extend OpenAI::Internal::Type::Union
  20. 1 discriminator :type
  21. # Default response format. Used to generate text responses.
  22. 1 variant :text, -> { OpenAI::ResponseFormatText }
  23. # JSON Schema response format. Used to generate structured JSON responses.
  24. # Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
  25. 1 variant :json_schema, -> { OpenAI::Responses::ResponseFormatTextJSONSchemaConfig }
  26. # An {OpenAI::BaseModel} can be provided and implicitly converted into {OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig}.
  27. # See examples for more details.
  28. #
  29. # Learn more about [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
  30. 1 variant -> { OpenAI::StructuredOutput::JsonSchemaConverter }
  31. # JSON object response format. An older method of generating JSON responses.
  32. # Using `json_schema` is recommended for models that support it. Note that the
  33. # model will not generate JSON without a system or user message instructing it
  34. # to do so.
  35. 1 variant :json_object, -> { OpenAI::ResponseFormatJSONObject }
  36. # @!method self.variants
  37. # @return [Array(OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject)]
  38. end
  39. end
  40. end
  41. end

openai-ruby/lib/openai/models/responses/response_format_text_json_schema_config.rb

90.0% lines covered

100.0% branches covered

10 relevant lines. 9 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFormatTextJSONSchemaConfig < OpenAI::Internal::Type::BaseModel
  6. # @!attribute name
  7. # The name of the response format. Must be a-z, A-Z, 0-9, or contain underscores
  8. # and dashes, with a maximum length of 64.
  9. #
  10. # @return [String]
  11. 1 required :name, String
  12. # @!attribute schema
  13. # The schema for the response format, described as a JSON Schema object. Learn how
  14. # to build JSON schemas [here](https://json-schema.org/).
  15. #
  16. # @return [Hash{Symbol=>Object}, OpenAI::StructuredOutput::JsonSchemaConverter]
  17. 1 required :schema,
  18. union: -> {
  19. OpenAI::UnionOf[
  20. OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown], OpenAI::StructuredOutput::JsonSchemaConverter
  21. ]
  22. }
  23. # @!attribute type
  24. # The type of response format being defined. Always `json_schema`.
  25. #
  26. # @return [Symbol, :json_schema]
  27. 1 required :type, const: :json_schema
  28. # @!attribute description
  29. # A description of what the response format is for, used by the model to determine
  30. # how to respond in the format.
  31. #
  32. # @return [String, nil]
  33. 1 optional :description, String
  34. # @!attribute strict
  35. # Whether to enable strict schema adherence when generating the output. If set to
  36. # true, the model will always follow the exact schema defined in the `schema`
  37. # field. Only a subset of JSON Schema is supported when `strict` is `true`. To
  38. # learn more, read the
  39. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  40. #
  41. # @return [Boolean, nil]
  42. 1 optional :strict, OpenAI::Internal::Type::Boolean, nil?: true
  43. # @!method initialize(name:, schema:, description: nil, strict: nil, type: :json_schema)
  44. # Some parameter documentations has been truncated, see
  45. # {OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig} for more
  46. # details.
  47. #
  48. # JSON Schema response format. Used to generate structured JSON responses. Learn
  49. # more about
  50. # [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs).
  51. #
  52. # @param name [String] The name of the response format. Must be a-z, A-Z, 0-9, or contain
  53. #
  54. # @param schema [Hash{Symbol=>Object}, OpenAI::StructuredOutput::JsonSchemaConverter] The schema for the response format, described as a JSON Schema object.
  55. #
  56. # @param description [String] A description of what the response format is for, used by the model to
  57. #
  58. # @param strict [Boolean, nil] Whether to enable strict schema adherence when generating the output.
  59. #
  60. # @param type [Symbol, :json_schema] The type of response format being defined. Always `json_schema`.
  61. end
  62. end
  63. end
  64. end

openai-ruby/lib/openai/models/responses/response_function_call_arguments_delta_event.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFunctionCallArgumentsDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute delta
  7. # The function-call arguments delta that is added.
  8. #
  9. # @return [String]
  10. 1 required :delta, String
  11. # @!attribute item_id
  12. # The ID of the output item that the function-call arguments delta is added to.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute output_index
  17. # The index of the output item that the function-call arguments delta is added to.
  18. #
  19. # @return [Integer]
  20. 1 required :output_index, Integer
  21. # @!attribute sequence_number
  22. # The sequence number of this event.
  23. #
  24. # @return [Integer]
  25. 1 required :sequence_number, Integer
  26. # @!attribute type
  27. # The type of the event. Always `response.function_call_arguments.delta`.
  28. #
  29. # @return [Symbol, :"response.function_call_arguments.delta"]
  30. 1 required :type, const: :"response.function_call_arguments.delta"
  31. # @!method initialize(delta:, item_id:, output_index:, sequence_number:, type: :"response.function_call_arguments.delta")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent} for more
  34. # details.
  35. #
  36. # Emitted when there is a partial function-call arguments delta.
  37. #
  38. # @param delta [String] The function-call arguments delta that is added.
  39. #
  40. # @param item_id [String] The ID of the output item that the function-call arguments delta is added to.
  41. #
  42. # @param output_index [Integer] The index of the output item that the function-call arguments delta is added to.
  43. #
  44. # @param sequence_number [Integer] The sequence number of this event.
  45. #
  46. # @param type [Symbol, :"response.function_call_arguments.delta"] The type of the event. Always `response.function_call_arguments.delta`.
  47. end
  48. end
  49. end
  50. end

openai-ruby/lib/openai/models/responses/response_function_call_arguments_done_event.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFunctionCallArgumentsDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute arguments
  7. # The function-call arguments.
  8. #
  9. # @return [String]
  10. 1 required :arguments, String
  11. # @!attribute item_id
  12. # The ID of the item.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute output_index
  17. # The index of the output item.
  18. #
  19. # @return [Integer]
  20. 1 required :output_index, Integer
  21. # @!attribute sequence_number
  22. # The sequence number of this event.
  23. #
  24. # @return [Integer]
  25. 1 required :sequence_number, Integer
  26. # @!attribute type
  27. #
  28. # @return [Symbol, :"response.function_call_arguments.done"]
  29. 1 required :type, const: :"response.function_call_arguments.done"
  30. # @!method initialize(arguments:, item_id:, output_index:, sequence_number:, type: :"response.function_call_arguments.done")
  31. # Emitted when function-call arguments are finalized.
  32. #
  33. # @param arguments [String] The function-call arguments.
  34. #
  35. # @param item_id [String] The ID of the item.
  36. #
  37. # @param output_index [Integer] The index of the output item.
  38. #
  39. # @param sequence_number [Integer] The sequence number of this event.
  40. #
  41. # @param type [Symbol, :"response.function_call_arguments.done"]
  42. end
  43. end
  44. end
  45. end

openai-ruby/lib/openai/models/responses/response_function_tool_call.rb

100.0% lines covered

100.0% branches covered

16 relevant lines. 16 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFunctionToolCall < OpenAI::Internal::Type::BaseModel
  6. # @!attribute arguments
  7. # A JSON string of the arguments to pass to the function.
  8. #
  9. # @return [String]
  10. 1 required :arguments, String
  11. # @!attribute parsed
  12. # The parsed contents of the arguments.
  13. #
  14. # @return [Object, nil]
  15. 1 required :parsed, OpenAI::StructuredOutput::ParsedJson
  16. # @!attribute call_id
  17. # The unique ID of the function tool call generated by the model.
  18. #
  19. # @return [String]
  20. 1 required :call_id, String
  21. # @!attribute name
  22. # The name of the function to run.
  23. #
  24. # @return [String]
  25. 1 required :name, String
  26. # @!attribute type
  27. # The type of the function tool call. Always `function_call`.
  28. #
  29. # @return [Symbol, :function_call]
  30. 1 required :type, const: :function_call
  31. # @!attribute id
  32. # The unique ID of the function tool call.
  33. #
  34. # @return [String, nil]
  35. 1 optional :id, String
  36. # @!attribute status
  37. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  38. # Populated when items are returned via API.
  39. #
  40. # @return [Symbol, OpenAI::Models::Responses::ResponseFunctionToolCall::Status, nil]
  41. 1 optional :status, enum: -> { OpenAI::Responses::ResponseFunctionToolCall::Status }
  42. # @!method initialize(arguments:, call_id:, name:, id: nil, status: nil, type: :function_call)
  43. # Some parameter documentations has been truncated, see
  44. # {OpenAI::Models::Responses::ResponseFunctionToolCall} for more details.
  45. #
  46. # A tool call to run a function. See the
  47. # [function calling guide](https://platform.openai.com/docs/guides/function-calling)
  48. # for more information.
  49. #
  50. # @param arguments [String] A JSON string of the arguments to pass to the function.
  51. #
  52. # @param call_id [String] The unique ID of the function tool call generated by the model.
  53. #
  54. # @param name [String] The name of the function to run.
  55. #
  56. # @param id [String] The unique ID of the function tool call.
  57. #
  58. # @param status [Symbol, OpenAI::Models::Responses::ResponseFunctionToolCall::Status] The status of the item. One of `in_progress`, `completed`, or
  59. #
  60. # @param type [Symbol, :function_call] The type of the function tool call. Always `function_call`.
  61. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  62. # Populated when items are returned via API.
  63. #
  64. # @see OpenAI::Models::Responses::ResponseFunctionToolCall#status
  65. 1 module Status
  66. 1 extend OpenAI::Internal::Type::Enum
  67. 1 IN_PROGRESS = :in_progress
  68. 1 COMPLETED = :completed
  69. 1 INCOMPLETE = :incomplete
  70. # @!method self.values
  71. # @return [Array<Symbol>]
  72. end
  73. end
  74. end
  75. end
  76. end

openai-ruby/lib/openai/models/responses/response_function_tool_call_item.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFunctionToolCallItem < OpenAI::Models::Responses::ResponseFunctionToolCall
  6. # @!attribute id
  7. # The unique ID of the function tool call.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!method initialize(id:)
  12. # Some parameter documentations has been truncated, see
  13. # {OpenAI::Models::Responses::ResponseFunctionToolCallItem} for more details.
  14. #
  15. # A tool call to run a function. See the
  16. # [function calling guide](https://platform.openai.com/docs/guides/function-calling)
  17. # for more information.
  18. #
  19. # @param id [String] The unique ID of the function tool call.
  20. end
  21. end
  22. end
  23. end

openai-ruby/lib/openai/models/responses/response_function_tool_call_output_item.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFunctionToolCallOutputItem < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the function call tool output.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute call_id
  12. # The unique ID of the function tool call generated by the model.
  13. #
  14. # @return [String]
  15. 1 required :call_id, String
  16. # @!attribute output
  17. # A JSON string of the output of the function tool call.
  18. #
  19. # @return [String]
  20. 1 required :output, String
  21. # @!attribute type
  22. # The type of the function tool call output. Always `function_call_output`.
  23. #
  24. # @return [Symbol, :function_call_output]
  25. 1 required :type, const: :function_call_output
  26. # @!attribute status
  27. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  28. # Populated when items are returned via API.
  29. #
  30. # @return [Symbol, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status, nil]
  31. 1 optional :status, enum: -> { OpenAI::Responses::ResponseFunctionToolCallOutputItem::Status }
  32. # @!method initialize(id:, call_id:, output:, status: nil, type: :function_call_output)
  33. # Some parameter documentations has been truncated, see
  34. # {OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem} for more
  35. # details.
  36. #
  37. # @param id [String] The unique ID of the function call tool output.
  38. #
  39. # @param call_id [String] The unique ID of the function tool call generated by the model.
  40. #
  41. # @param output [String] A JSON string of the output of the function tool call.
  42. #
  43. # @param status [Symbol, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem::Status] The status of the item. One of `in_progress`, `completed`, or
  44. #
  45. # @param type [Symbol, :function_call_output] The type of the function tool call output. Always `function_call_output`.
  46. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  47. # Populated when items are returned via API.
  48. #
  49. # @see OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem#status
  50. 1 module Status
  51. 1 extend OpenAI::Internal::Type::Enum
  52. 1 IN_PROGRESS = :in_progress
  53. 1 COMPLETED = :completed
  54. 1 INCOMPLETE = :incomplete
  55. # @!method self.values
  56. # @return [Array<Symbol>]
  57. end
  58. end
  59. end
  60. end
  61. end

openai-ruby/lib/openai/models/responses/response_function_web_search.rb

100.0% lines covered

100.0% branches covered

30 relevant lines. 30 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseFunctionWebSearch < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the web search tool call.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute action
  12. # An object describing the specific action taken in this web search call. Includes
  13. # details on how the model used the web (search, open_page, find).
  14. #
  15. # @return [OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::Search, OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::OpenPage, OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::Find]
  16. 1 required :action, union: -> { OpenAI::Responses::ResponseFunctionWebSearch::Action }
  17. # @!attribute status
  18. # The status of the web search tool call.
  19. #
  20. # @return [Symbol, OpenAI::Models::Responses::ResponseFunctionWebSearch::Status]
  21. 1 required :status, enum: -> { OpenAI::Responses::ResponseFunctionWebSearch::Status }
  22. # @!attribute type
  23. # The type of the web search tool call. Always `web_search_call`.
  24. #
  25. # @return [Symbol, :web_search_call]
  26. 1 required :type, const: :web_search_call
  27. # @!method initialize(id:, action:, status:, type: :web_search_call)
  28. # Some parameter documentations has been truncated, see
  29. # {OpenAI::Models::Responses::ResponseFunctionWebSearch} for more details.
  30. #
  31. # The results of a web search tool call. See the
  32. # [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for
  33. # more information.
  34. #
  35. # @param id [String] The unique ID of the web search tool call.
  36. #
  37. # @param action [OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::Search, OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::OpenPage, OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::Find] An object describing the specific action taken in this web search call.
  38. #
  39. # @param status [Symbol, OpenAI::Models::Responses::ResponseFunctionWebSearch::Status] The status of the web search tool call.
  40. #
  41. # @param type [Symbol, :web_search_call] The type of the web search tool call. Always `web_search_call`.
  42. # An object describing the specific action taken in this web search call. Includes
  43. # details on how the model used the web (search, open_page, find).
  44. #
  45. # @see OpenAI::Models::Responses::ResponseFunctionWebSearch#action
  46. 1 module Action
  47. 1 extend OpenAI::Internal::Type::Union
  48. 1 discriminator :type
  49. # Action type "search" - Performs a web search query.
  50. 1 variant :search, -> { OpenAI::Responses::ResponseFunctionWebSearch::Action::Search }
  51. # Action type "open_page" - Opens a specific URL from search results.
  52. 1 variant :open_page, -> { OpenAI::Responses::ResponseFunctionWebSearch::Action::OpenPage }
  53. # Action type "find": Searches for a pattern within a loaded page.
  54. 1 variant :find, -> { OpenAI::Responses::ResponseFunctionWebSearch::Action::Find }
  55. 1 class Search < OpenAI::Internal::Type::BaseModel
  56. # @!attribute query
  57. # The search query.
  58. #
  59. # @return [String]
  60. 1 required :query, String
  61. # @!attribute type
  62. # The action type.
  63. #
  64. # @return [Symbol, :search]
  65. 1 required :type, const: :search
  66. # @!method initialize(query:, type: :search)
  67. # Some parameter documentations has been truncated, see
  68. # {OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::Search} for more
  69. # details.
  70. #
  71. # Action type "search" - Performs a web search query.
  72. #
  73. # @param query [String] The search query.
  74. #
  75. # @param type [Symbol, :search] The action type.
  76. end
  77. 1 class OpenPage < OpenAI::Internal::Type::BaseModel
  78. # @!attribute type
  79. # The action type.
  80. #
  81. # @return [Symbol, :open_page]
  82. 1 required :type, const: :open_page
  83. # @!attribute url
  84. # The URL opened by the model.
  85. #
  86. # @return [String]
  87. 1 required :url, String
  88. # @!method initialize(url:, type: :open_page)
  89. # Some parameter documentations has been truncated, see
  90. # {OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::OpenPage} for
  91. # more details.
  92. #
  93. # Action type "open_page" - Opens a specific URL from search results.
  94. #
  95. # @param url [String] The URL opened by the model.
  96. #
  97. # @param type [Symbol, :open_page] The action type.
  98. end
  99. 1 class Find < OpenAI::Internal::Type::BaseModel
  100. # @!attribute pattern
  101. # The pattern or text to search for within the page.
  102. #
  103. # @return [String]
  104. 1 required :pattern, String
  105. # @!attribute type
  106. # The action type.
  107. #
  108. # @return [Symbol, :find]
  109. 1 required :type, const: :find
  110. # @!attribute url
  111. # The URL of the page searched for the pattern.
  112. #
  113. # @return [String]
  114. 1 required :url, String
  115. # @!method initialize(pattern:, url:, type: :find)
  116. # Some parameter documentations has been truncated, see
  117. # {OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::Find} for more
  118. # details.
  119. #
  120. # Action type "find": Searches for a pattern within a loaded page.
  121. #
  122. # @param pattern [String] The pattern or text to search for within the page.
  123. #
  124. # @param url [String] The URL of the page searched for the pattern.
  125. #
  126. # @param type [Symbol, :find] The action type.
  127. end
  128. # @!method self.variants
  129. # @return [Array(OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::Search, OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::OpenPage, OpenAI::Models::Responses::ResponseFunctionWebSearch::Action::Find)]
  130. end
  131. # The status of the web search tool call.
  132. #
  133. # @see OpenAI::Models::Responses::ResponseFunctionWebSearch#status
  134. 1 module Status
  135. 1 extend OpenAI::Internal::Type::Enum
  136. 1 IN_PROGRESS = :in_progress
  137. 1 SEARCHING = :searching
  138. 1 COMPLETED = :completed
  139. 1 FAILED = :failed
  140. # @!method self.values
  141. # @return [Array<Symbol>]
  142. end
  143. end
  144. end
  145. end
  146. end

openai-ruby/lib/openai/models/responses/response_image_gen_call_completed_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseImageGenCallCompletedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The unique identifier of the image generation item being processed.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item in the response's output array.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always 'response.image_generation_call.completed'.
  23. #
  24. # @return [Symbol, :"response.image_generation_call.completed"]
  25. 1 required :type, const: :"response.image_generation_call.completed"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.image_generation_call.completed")
  27. # Emitted when an image generation tool call has completed and the final image is
  28. # available.
  29. #
  30. # @param item_id [String] The unique identifier of the image generation item being processed.
  31. #
  32. # @param output_index [Integer] The index of the output item in the response's output array.
  33. #
  34. # @param sequence_number [Integer] The sequence number of this event.
  35. #
  36. # @param type [Symbol, :"response.image_generation_call.completed"] The type of the event. Always 'response.image_generation_call.completed'.
  37. end
  38. end
  39. end
  40. end

openai-ruby/lib/openai/models/responses/response_image_gen_call_generating_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseImageGenCallGeneratingEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The unique identifier of the image generation item being processed.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item in the response's output array.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of the image generation item being processed.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always 'response.image_generation_call.generating'.
  23. #
  24. # @return [Symbol, :"response.image_generation_call.generating"]
  25. 1 required :type, const: :"response.image_generation_call.generating"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.image_generation_call.generating")
  27. # Emitted when an image generation tool call is actively generating an image
  28. # (intermediate state).
  29. #
  30. # @param item_id [String] The unique identifier of the image generation item being processed.
  31. #
  32. # @param output_index [Integer] The index of the output item in the response's output array.
  33. #
  34. # @param sequence_number [Integer] The sequence number of the image generation item being processed.
  35. #
  36. # @param type [Symbol, :"response.image_generation_call.generating"] The type of the event. Always 'response.image_generation_call.generating'.
  37. end
  38. end
  39. end
  40. end

openai-ruby/lib/openai/models/responses/response_image_gen_call_in_progress_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseImageGenCallInProgressEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The unique identifier of the image generation item being processed.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item in the response's output array.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of the image generation item being processed.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always 'response.image_generation_call.in_progress'.
  23. #
  24. # @return [Symbol, :"response.image_generation_call.in_progress"]
  25. 1 required :type, const: :"response.image_generation_call.in_progress"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.image_generation_call.in_progress")
  27. # Emitted when an image generation tool call is in progress.
  28. #
  29. # @param item_id [String] The unique identifier of the image generation item being processed.
  30. #
  31. # @param output_index [Integer] The index of the output item in the response's output array.
  32. #
  33. # @param sequence_number [Integer] The sequence number of the image generation item being processed.
  34. #
  35. # @param type [Symbol, :"response.image_generation_call.in_progress"] The type of the event. Always 'response.image_generation_call.in_progress'.
  36. end
  37. end
  38. end
  39. end

openai-ruby/lib/openai/models/responses/response_image_gen_call_partial_image_event.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseImageGenCallPartialImageEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The unique identifier of the image generation item being processed.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item in the response's output array.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute partial_image_b64
  17. # Base64-encoded partial image data, suitable for rendering as an image.
  18. #
  19. # @return [String]
  20. 1 required :partial_image_b64, String
  21. # @!attribute partial_image_index
  22. # 0-based index for the partial image (backend is 1-based, but this is 0-based for
  23. # the user).
  24. #
  25. # @return [Integer]
  26. 1 required :partial_image_index, Integer
  27. # @!attribute sequence_number
  28. # The sequence number of the image generation item being processed.
  29. #
  30. # @return [Integer]
  31. 1 required :sequence_number, Integer
  32. # @!attribute type
  33. # The type of the event. Always 'response.image_generation_call.partial_image'.
  34. #
  35. # @return [Symbol, :"response.image_generation_call.partial_image"]
  36. 1 required :type, const: :"response.image_generation_call.partial_image"
  37. # @!method initialize(item_id:, output_index:, partial_image_b64:, partial_image_index:, sequence_number:, type: :"response.image_generation_call.partial_image")
  38. # Some parameter documentations has been truncated, see
  39. # {OpenAI::Models::Responses::ResponseImageGenCallPartialImageEvent} for more
  40. # details.
  41. #
  42. # Emitted when a partial image is available during image generation streaming.
  43. #
  44. # @param item_id [String] The unique identifier of the image generation item being processed.
  45. #
  46. # @param output_index [Integer] The index of the output item in the response's output array.
  47. #
  48. # @param partial_image_b64 [String] Base64-encoded partial image data, suitable for rendering as an image.
  49. #
  50. # @param partial_image_index [Integer] 0-based index for the partial image (backend is 1-based, but this is 0-based for
  51. #
  52. # @param sequence_number [Integer] The sequence number of the image generation item being processed.
  53. #
  54. # @param type [Symbol, :"response.image_generation_call.partial_image"] The type of the event. Always 'response.image_generation_call.partial_image'.
  55. end
  56. end
  57. end
  58. end

openai-ruby/lib/openai/models/responses/response_in_progress_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseInProgressEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute response
  7. # The response that is in progress.
  8. #
  9. # @return [OpenAI::Models::Responses::Response]
  10. 1 required :response, -> { OpenAI::Responses::Response }
  11. # @!attribute sequence_number
  12. # The sequence number of this event.
  13. #
  14. # @return [Integer]
  15. 1 required :sequence_number, Integer
  16. # @!attribute type
  17. # The type of the event. Always `response.in_progress`.
  18. #
  19. # @return [Symbol, :"response.in_progress"]
  20. 1 required :type, const: :"response.in_progress"
  21. # @!method initialize(response:, sequence_number:, type: :"response.in_progress")
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ResponseInProgressEvent} for more details.
  24. #
  25. # Emitted when the response is in progress.
  26. #
  27. # @param response [OpenAI::Models::Responses::Response] The response that is in progress.
  28. #
  29. # @param sequence_number [Integer] The sequence number of this event.
  30. #
  31. # @param type [Symbol, :"response.in_progress"] The type of the event. Always `response.in_progress`.
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/responses/response_includable.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # Specify additional output data to include in the model response. Currently
  6. # supported values are:
  7. #
  8. # - `code_interpreter_call.outputs`: Includes the outputs of python code execution
  9. # in code interpreter tool call items.
  10. # - `computer_call_output.output.image_url`: Include image urls from the computer
  11. # call output.
  12. # - `file_search_call.results`: Include the search results of the file search tool
  13. # call.
  14. # - `message.input_image.image_url`: Include image urls from the input message.
  15. # - `message.output_text.logprobs`: Include logprobs with assistant messages.
  16. # - `reasoning.encrypted_content`: Includes an encrypted version of reasoning
  17. # tokens in reasoning item outputs. This enables reasoning items to be used in
  18. # multi-turn conversations when using the Responses API statelessly (like when
  19. # the `store` parameter is set to `false`, or when an organization is enrolled
  20. # in the zero data retention program).
  21. 1 module ResponseIncludable
  22. 1 extend OpenAI::Internal::Type::Enum
  23. 1 CODE_INTERPRETER_CALL_OUTPUTS = :"code_interpreter_call.outputs"
  24. 1 COMPUTER_CALL_OUTPUT_OUTPUT_IMAGE_URL = :"computer_call_output.output.image_url"
  25. 1 FILE_SEARCH_CALL_RESULTS = :"file_search_call.results"
  26. 1 MESSAGE_INPUT_IMAGE_IMAGE_URL = :"message.input_image.image_url"
  27. 1 MESSAGE_OUTPUT_TEXT_LOGPROBS = :"message.output_text.logprobs"
  28. 1 REASONING_ENCRYPTED_CONTENT = :"reasoning.encrypted_content"
  29. # @!method self.values
  30. # @return [Array<Symbol>]
  31. end
  32. end
  33. end
  34. end

openai-ruby/lib/openai/models/responses/response_incomplete_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseIncompleteEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute response
  7. # The response that was incomplete.
  8. #
  9. # @return [OpenAI::Models::Responses::Response]
  10. 1 required :response, -> { OpenAI::Responses::Response }
  11. # @!attribute sequence_number
  12. # The sequence number of this event.
  13. #
  14. # @return [Integer]
  15. 1 required :sequence_number, Integer
  16. # @!attribute type
  17. # The type of the event. Always `response.incomplete`.
  18. #
  19. # @return [Symbol, :"response.incomplete"]
  20. 1 required :type, const: :"response.incomplete"
  21. # @!method initialize(response:, sequence_number:, type: :"response.incomplete")
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ResponseIncompleteEvent} for more details.
  24. #
  25. # An event that is emitted when a response finishes as incomplete.
  26. #
  27. # @param response [OpenAI::Models::Responses::Response] The response that was incomplete.
  28. #
  29. # @param sequence_number [Integer] The sequence number of this event.
  30. #
  31. # @param type [Symbol, :"response.incomplete"] The type of the event. Always `response.incomplete`.
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/responses/response_input.rb

100.0% lines covered

100.0% branches covered

4 relevant lines. 4 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # @type [OpenAI::Internal::Type::Converter]
  6. 3 ResponseInput = OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Responses::ResponseInputItem }]
  7. end
  8. end
  9. end

openai-ruby/lib/openai/models/responses/response_input_audio.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseInputAudio < OpenAI::Internal::Type::BaseModel
  6. # @!attribute data
  7. # Base64-encoded audio data.
  8. #
  9. # @return [String]
  10. 1 required :data, String
  11. # @!attribute format_
  12. # The format of the audio data. Currently supported formats are `mp3` and `wav`.
  13. #
  14. # @return [Symbol, OpenAI::Models::Responses::ResponseInputAudio::Format]
  15. 1 required :format_, enum: -> { OpenAI::Responses::ResponseInputAudio::Format }, api_name: :format
  16. # @!attribute type
  17. # The type of the input item. Always `input_audio`.
  18. #
  19. # @return [Symbol, :input_audio]
  20. 1 required :type, const: :input_audio
  21. # @!method initialize(data:, format_:, type: :input_audio)
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ResponseInputAudio} for more details.
  24. #
  25. # An audio input to the model.
  26. #
  27. # @param data [String] Base64-encoded audio data.
  28. #
  29. # @param format_ [Symbol, OpenAI::Models::Responses::ResponseInputAudio::Format] The format of the audio data. Currently supported formats are `mp3` and
  30. #
  31. # @param type [Symbol, :input_audio] The type of the input item. Always `input_audio`.
  32. # The format of the audio data. Currently supported formats are `mp3` and `wav`.
  33. #
  34. # @see OpenAI::Models::Responses::ResponseInputAudio#format_
  35. 1 module Format
  36. 1 extend OpenAI::Internal::Type::Enum
  37. 1 MP3 = :mp3
  38. 1 WAV = :wav
  39. # @!method self.values
  40. # @return [Array<Symbol>]
  41. end
  42. end
  43. end
  44. end
  45. end

openai-ruby/lib/openai/models/responses/response_input_content.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # A text input to the model.
  6. 1 module ResponseInputContent
  7. 1 extend OpenAI::Internal::Type::Union
  8. 1 discriminator :type
  9. # A text input to the model.
  10. 1 variant :input_text, -> { OpenAI::Responses::ResponseInputText }
  11. # An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
  12. 1 variant :input_image, -> { OpenAI::Responses::ResponseInputImage }
  13. # A file input to the model.
  14. 1 variant :input_file, -> { OpenAI::Responses::ResponseInputFile }
  15. # @!method self.variants
  16. # @return [Array(OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile)]
  17. end
  18. end
  19. end
  20. end

openai-ruby/lib/openai/models/responses/response_input_file.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseInputFile < OpenAI::Internal::Type::BaseModel
  6. # @!attribute type
  7. # The type of the input item. Always `input_file`.
  8. #
  9. # @return [Symbol, :input_file]
  10. 1 required :type, const: :input_file
  11. # @!attribute file_data
  12. # The content of the file to be sent to the model.
  13. #
  14. # @return [String, nil]
  15. 1 optional :file_data, String
  16. # @!attribute file_id
  17. # The ID of the file to be sent to the model.
  18. #
  19. # @return [String, nil]
  20. 1 optional :file_id, String, nil?: true
  21. # @!attribute file_url
  22. # The URL of the file to be sent to the model.
  23. #
  24. # @return [String, nil]
  25. 1 optional :file_url, String
  26. # @!attribute filename
  27. # The name of the file to be sent to the model.
  28. #
  29. # @return [String, nil]
  30. 1 optional :filename, String
  31. # @!method initialize(file_data: nil, file_id: nil, file_url: nil, filename: nil, type: :input_file)
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Responses::ResponseInputFile} for more details.
  34. #
  35. # A file input to the model.
  36. #
  37. # @param file_data [String] The content of the file to be sent to the model.
  38. #
  39. # @param file_id [String, nil] The ID of the file to be sent to the model.
  40. #
  41. # @param file_url [String] The URL of the file to be sent to the model.
  42. #
  43. # @param filename [String] The name of the file to be sent to the model.
  44. #
  45. # @param type [Symbol, :input_file] The type of the input item. Always `input_file`.
  46. end
  47. end
  48. end
  49. end

openai-ruby/lib/openai/models/responses/response_input_image.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseInputImage < OpenAI::Internal::Type::BaseModel
  6. # @!attribute detail
  7. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  8. # `auto`. Defaults to `auto`.
  9. #
  10. # @return [Symbol, OpenAI::Models::Responses::ResponseInputImage::Detail]
  11. 1 required :detail, enum: -> { OpenAI::Responses::ResponseInputImage::Detail }
  12. # @!attribute type
  13. # The type of the input item. Always `input_image`.
  14. #
  15. # @return [Symbol, :input_image]
  16. 1 required :type, const: :input_image
  17. # @!attribute file_id
  18. # The ID of the file to be sent to the model.
  19. #
  20. # @return [String, nil]
  21. 1 optional :file_id, String, nil?: true
  22. # @!attribute image_url
  23. # The URL of the image to be sent to the model. A fully qualified URL or base64
  24. # encoded image in a data URL.
  25. #
  26. # @return [String, nil]
  27. 1 optional :image_url, String, nil?: true
  28. # @!method initialize(detail:, file_id: nil, image_url: nil, type: :input_image)
  29. # Some parameter documentations has been truncated, see
  30. # {OpenAI::Models::Responses::ResponseInputImage} for more details.
  31. #
  32. # An image input to the model. Learn about
  33. # [image inputs](https://platform.openai.com/docs/guides/vision).
  34. #
  35. # @param detail [Symbol, OpenAI::Models::Responses::ResponseInputImage::Detail] The detail level of the image to be sent to the model. One of `high`, `low`, or
  36. #
  37. # @param file_id [String, nil] The ID of the file to be sent to the model.
  38. #
  39. # @param image_url [String, nil] The URL of the image to be sent to the model. A fully qualified URL or base64 en
  40. #
  41. # @param type [Symbol, :input_image] The type of the input item. Always `input_image`.
  42. # The detail level of the image to be sent to the model. One of `high`, `low`, or
  43. # `auto`. Defaults to `auto`.
  44. #
  45. # @see OpenAI::Models::Responses::ResponseInputImage#detail
  46. 1 module Detail
  47. 1 extend OpenAI::Internal::Type::Enum
  48. 1 LOW = :low
  49. 1 HIGH = :high
  50. 1 AUTO = :auto
  51. # @!method self.values
  52. # @return [Array<Symbol>]
  53. end
  54. end
  55. end
  56. end
  57. end

openai-ruby/lib/openai/models/responses/response_input_item.rb

96.05% lines covered

100.0% branches covered

152 relevant lines. 146 lines covered and 6 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # A message input to the model with a role indicating instruction following
  6. # hierarchy. Instructions given with the `developer` or `system` role take
  7. # precedence over instructions given with the `user` role. Messages with the
  8. # `assistant` role are presumed to have been generated by the model in previous
  9. # interactions.
  10. 1 module ResponseInputItem
  11. 1 extend OpenAI::Internal::Type::Union
  12. 1 discriminator :type
  13. # A message input to the model with a role indicating instruction following
  14. # hierarchy. Instructions given with the `developer` or `system` role take
  15. # precedence over instructions given with the `user` role. Messages with the
  16. # `assistant` role are presumed to have been generated by the model in previous
  17. # interactions.
  18. 3 variant :message, -> { OpenAI::Responses::EasyInputMessage }
  19. # A message input to the model with a role indicating instruction following
  20. # hierarchy. Instructions given with the `developer` or `system` role take
  21. # precedence over instructions given with the `user` role.
  22. 3 variant :message, -> { OpenAI::Responses::ResponseInputItem::Message }
  23. # An output message from the model.
  24. 3 variant :message, -> { OpenAI::Responses::ResponseOutputMessage }
  25. # The results of a file search tool call. See the
  26. # [file search guide](https://platform.openai.com/docs/guides/tools-file-search) for more information.
  27. 3 variant :file_search_call, -> { OpenAI::Responses::ResponseFileSearchToolCall }
  28. # A tool call to a computer use tool. See the
  29. # [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use) for more information.
  30. 3 variant :computer_call, -> { OpenAI::Responses::ResponseComputerToolCall }
  31. # The output of a computer tool call.
  32. 3 variant :computer_call_output, -> { OpenAI::Responses::ResponseInputItem::ComputerCallOutput }
  33. # The results of a web search tool call. See the
  34. # [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for more information.
  35. 3 variant :web_search_call, -> { OpenAI::Responses::ResponseFunctionWebSearch }
  36. # A tool call to run a function. See the
  37. # [function calling guide](https://platform.openai.com/docs/guides/function-calling) for more information.
  38. 3 variant :function_call, -> { OpenAI::Responses::ResponseFunctionToolCall }
  39. # The output of a function tool call.
  40. 3 variant :function_call_output, -> { OpenAI::Responses::ResponseInputItem::FunctionCallOutput }
  41. # A description of the chain of thought used by a reasoning model while generating
  42. # a response. Be sure to include these items in your `input` to the Responses API
  43. # for subsequent turns of a conversation if you are manually
  44. # [managing context](https://platform.openai.com/docs/guides/conversation-state).
  45. 3 variant :reasoning, -> { OpenAI::Responses::ResponseReasoningItem }
  46. # An image generation request made by the model.
  47. 3 variant :image_generation_call, -> { OpenAI::Responses::ResponseInputItem::ImageGenerationCall }
  48. # A tool call to run code.
  49. 3 variant :code_interpreter_call, -> { OpenAI::Responses::ResponseCodeInterpreterToolCall }
  50. # A tool call to run a command on the local shell.
  51. 3 variant :local_shell_call, -> { OpenAI::Responses::ResponseInputItem::LocalShellCall }
  52. # The output of a local shell tool call.
  53. 3 variant :local_shell_call_output, -> { OpenAI::Responses::ResponseInputItem::LocalShellCallOutput }
  54. # A list of tools available on an MCP server.
  55. 3 variant :mcp_list_tools, -> { OpenAI::Responses::ResponseInputItem::McpListTools }
  56. # A request for human approval of a tool invocation.
  57. 3 variant :mcp_approval_request, -> { OpenAI::Responses::ResponseInputItem::McpApprovalRequest }
  58. # A response to an MCP approval request.
  59. 3 variant :mcp_approval_response, -> { OpenAI::Responses::ResponseInputItem::McpApprovalResponse }
  60. # An invocation of a tool on an MCP server.
  61. 3 variant :mcp_call, -> { OpenAI::Responses::ResponseInputItem::McpCall }
  62. # An internal identifier for an item to reference.
  63. 3 variant :item_reference, -> { OpenAI::Responses::ResponseInputItem::ItemReference }
  64. 1 class Message < OpenAI::Internal::Type::BaseModel
  65. # @!attribute content
  66. # A list of one or many input items to the model, containing different content
  67. # types.
  68. #
  69. # @return [Array<OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile>]
  70. 1 required :content,
  71. -> {
  72. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::ResponseInputContent]
  73. }
  74. # @!attribute role
  75. # The role of the message input. One of `user`, `system`, or `developer`.
  76. #
  77. # @return [Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Role]
  78. 1 required :role, enum: -> { OpenAI::Responses::ResponseInputItem::Message::Role }
  79. # @!attribute status
  80. # The status of item. One of `in_progress`, `completed`, or `incomplete`.
  81. # Populated when items are returned via API.
  82. #
  83. # @return [Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Status, nil]
  84. 1 optional :status, enum: -> { OpenAI::Responses::ResponseInputItem::Message::Status }
  85. # @!attribute type
  86. # The type of the message input. Always set to `message`.
  87. #
  88. # @return [Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Type, nil]
  89. 1 optional :type, enum: -> { OpenAI::Responses::ResponseInputItem::Message::Type }
  90. # @!method initialize(content:, role:, status: nil, type: nil)
  91. # Some parameter documentations has been truncated, see
  92. # {OpenAI::Models::Responses::ResponseInputItem::Message} for more details.
  93. #
  94. # A message input to the model with a role indicating instruction following
  95. # hierarchy. Instructions given with the `developer` or `system` role take
  96. # precedence over instructions given with the `user` role.
  97. #
  98. # @param content [Array<OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile>] A list of one or many input items to the model, containing different content
  99. #
  100. # @param role [Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Role] The role of the message input. One of `user`, `system`, or `developer`.
  101. #
  102. # @param status [Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Status] The status of item. One of `in_progress`, `completed`, or
  103. #
  104. # @param type [Symbol, OpenAI::Models::Responses::ResponseInputItem::Message::Type] The type of the message input. Always set to `message`.
  105. # The role of the message input. One of `user`, `system`, or `developer`.
  106. #
  107. # @see OpenAI::Models::Responses::ResponseInputItem::Message#role
  108. 1 module Role
  109. 1 extend OpenAI::Internal::Type::Enum
  110. 1 USER = :user
  111. 1 SYSTEM = :system
  112. 1 DEVELOPER = :developer
  113. # @!method self.values
  114. # @return [Array<Symbol>]
  115. end
  116. # The status of item. One of `in_progress`, `completed`, or `incomplete`.
  117. # Populated when items are returned via API.
  118. #
  119. # @see OpenAI::Models::Responses::ResponseInputItem::Message#status
  120. 1 module Status
  121. 1 extend OpenAI::Internal::Type::Enum
  122. 1 IN_PROGRESS = :in_progress
  123. 1 COMPLETED = :completed
  124. 1 INCOMPLETE = :incomplete
  125. # @!method self.values
  126. # @return [Array<Symbol>]
  127. end
  128. # The type of the message input. Always set to `message`.
  129. #
  130. # @see OpenAI::Models::Responses::ResponseInputItem::Message#type
  131. 1 module Type
  132. 1 extend OpenAI::Internal::Type::Enum
  133. 1 MESSAGE = :message
  134. # @!method self.values
  135. # @return [Array<Symbol>]
  136. end
  137. end
  138. 1 class ComputerCallOutput < OpenAI::Internal::Type::BaseModel
  139. # @!attribute call_id
  140. # The ID of the computer tool call that produced the output.
  141. #
  142. # @return [String]
  143. 1 required :call_id, String
  144. # @!attribute output
  145. # A computer screenshot image used with the computer use tool.
  146. #
  147. # @return [OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot]
  148. 1 required :output, -> { OpenAI::Responses::ResponseComputerToolCallOutputScreenshot }
  149. # @!attribute type
  150. # The type of the computer tool call output. Always `computer_call_output`.
  151. #
  152. # @return [Symbol, :computer_call_output]
  153. 1 required :type, const: :computer_call_output
  154. # @!attribute id
  155. # The ID of the computer tool call output.
  156. #
  157. # @return [String, nil]
  158. 1 optional :id, String, nil?: true
  159. # @!attribute acknowledged_safety_checks
  160. # The safety checks reported by the API that have been acknowledged by the
  161. # developer.
  162. #
  163. # @return [Array<OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck>, nil]
  164. 1 optional :acknowledged_safety_checks,
  165. -> {
  166. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck]
  167. },
  168. nil?: true
  169. # @!attribute status
  170. # The status of the message input. One of `in_progress`, `completed`, or
  171. # `incomplete`. Populated when input items are returned via API.
  172. #
  173. # @return [Symbol, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status, nil]
  174. 1 optional :status,
  175. enum: -> { OpenAI::Responses::ResponseInputItem::ComputerCallOutput::Status },
  176. nil?: true
  177. # @!method initialize(call_id:, output:, id: nil, acknowledged_safety_checks: nil, status: nil, type: :computer_call_output)
  178. # Some parameter documentations has been truncated, see
  179. # {OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput} for more
  180. # details.
  181. #
  182. # The output of a computer tool call.
  183. #
  184. # @param call_id [String] The ID of the computer tool call that produced the output.
  185. #
  186. # @param output [OpenAI::Models::Responses::ResponseComputerToolCallOutputScreenshot] A computer screenshot image used with the computer use tool.
  187. #
  188. # @param id [String, nil] The ID of the computer tool call output.
  189. #
  190. # @param acknowledged_safety_checks [Array<OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::AcknowledgedSafetyCheck>, nil] The safety checks reported by the API that have been acknowledged by the develop
  191. #
  192. # @param status [Symbol, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput::Status, nil] The status of the message input. One of `in_progress`, `completed`, or `incomple
  193. #
  194. # @param type [Symbol, :computer_call_output] The type of the computer tool call output. Always `computer_call_output`.
  195. 1 class AcknowledgedSafetyCheck < OpenAI::Internal::Type::BaseModel
  196. # @!attribute id
  197. # The ID of the pending safety check.
  198. #
  199. # @return [String]
  200. 1 required :id, String
  201. # @!attribute code
  202. # The type of the pending safety check.
  203. #
  204. # @return [String, nil]
  205. 1 optional :code, String, nil?: true
  206. # @!attribute message
  207. # Details about the pending safety check.
  208. #
  209. # @return [String, nil]
  210. 1 optional :message, String, nil?: true
  211. # @!method initialize(id:, code: nil, message: nil)
  212. # A pending safety check for the computer call.
  213. #
  214. # @param id [String] The ID of the pending safety check.
  215. #
  216. # @param code [String, nil] The type of the pending safety check.
  217. #
  218. # @param message [String, nil] Details about the pending safety check.
  219. end
  220. # The status of the message input. One of `in_progress`, `completed`, or
  221. # `incomplete`. Populated when input items are returned via API.
  222. #
  223. # @see OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput#status
  224. 1 module Status
  225. 1 extend OpenAI::Internal::Type::Enum
  226. 1 IN_PROGRESS = :in_progress
  227. 1 COMPLETED = :completed
  228. 1 INCOMPLETE = :incomplete
  229. # @!method self.values
  230. # @return [Array<Symbol>]
  231. end
  232. end
  233. 1 class FunctionCallOutput < OpenAI::Internal::Type::BaseModel
  234. # @!attribute call_id
  235. # The unique ID of the function tool call generated by the model.
  236. #
  237. # @return [String]
  238. 1 required :call_id, String
  239. # @!attribute output
  240. # A JSON string of the output of the function tool call.
  241. #
  242. # @return [String]
  243. 1 required :output, String
  244. # @!attribute type
  245. # The type of the function tool call output. Always `function_call_output`.
  246. #
  247. # @return [Symbol, :function_call_output]
  248. 1 required :type, const: :function_call_output
  249. # @!attribute id
  250. # The unique ID of the function tool call output. Populated when this item is
  251. # returned via API.
  252. #
  253. # @return [String, nil]
  254. 1 optional :id, String, nil?: true
  255. # @!attribute status
  256. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  257. # Populated when items are returned via API.
  258. #
  259. # @return [Symbol, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status, nil]
  260. 1 optional :status,
  261. enum: -> { OpenAI::Responses::ResponseInputItem::FunctionCallOutput::Status },
  262. nil?: true
  263. # @!method initialize(call_id:, output:, id: nil, status: nil, type: :function_call_output)
  264. # Some parameter documentations has been truncated, see
  265. # {OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput} for more
  266. # details.
  267. #
  268. # The output of a function tool call.
  269. #
  270. # @param call_id [String] The unique ID of the function tool call generated by the model.
  271. #
  272. # @param output [String] A JSON string of the output of the function tool call.
  273. #
  274. # @param id [String, nil] The unique ID of the function tool call output. Populated when this item is retu
  275. #
  276. # @param status [Symbol, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput::Status, nil] The status of the item. One of `in_progress`, `completed`, or `incomplete`. Popu
  277. #
  278. # @param type [Symbol, :function_call_output] The type of the function tool call output. Always `function_call_output`.
  279. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  280. # Populated when items are returned via API.
  281. #
  282. # @see OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput#status
  283. 1 module Status
  284. 1 extend OpenAI::Internal::Type::Enum
  285. 1 IN_PROGRESS = :in_progress
  286. 1 COMPLETED = :completed
  287. 1 INCOMPLETE = :incomplete
  288. # @!method self.values
  289. # @return [Array<Symbol>]
  290. end
  291. end
  292. 1 class ImageGenerationCall < OpenAI::Internal::Type::BaseModel
  293. # @!attribute id
  294. # The unique ID of the image generation call.
  295. #
  296. # @return [String]
  297. 1 required :id, String
  298. # @!attribute result
  299. # The generated image encoded in base64.
  300. #
  301. # @return [String, nil]
  302. 1 required :result, String, nil?: true
  303. # @!attribute status
  304. # The status of the image generation call.
  305. #
  306. # @return [Symbol, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall::Status]
  307. 1 required :status, enum: -> { OpenAI::Responses::ResponseInputItem::ImageGenerationCall::Status }
  308. # @!attribute type
  309. # The type of the image generation call. Always `image_generation_call`.
  310. #
  311. # @return [Symbol, :image_generation_call]
  312. 1 required :type, const: :image_generation_call
  313. # @!method initialize(id:, result:, status:, type: :image_generation_call)
  314. # Some parameter documentations has been truncated, see
  315. # {OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall} for more
  316. # details.
  317. #
  318. # An image generation request made by the model.
  319. #
  320. # @param id [String] The unique ID of the image generation call.
  321. #
  322. # @param result [String, nil] The generated image encoded in base64.
  323. #
  324. # @param status [Symbol, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall::Status] The status of the image generation call.
  325. #
  326. # @param type [Symbol, :image_generation_call] The type of the image generation call. Always `image_generation_call`.
  327. # The status of the image generation call.
  328. #
  329. # @see OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall#status
  330. 1 module Status
  331. 1 extend OpenAI::Internal::Type::Enum
  332. 1 IN_PROGRESS = :in_progress
  333. 1 COMPLETED = :completed
  334. 1 GENERATING = :generating
  335. 1 FAILED = :failed
  336. # @!method self.values
  337. # @return [Array<Symbol>]
  338. end
  339. end
  340. 1 class LocalShellCall < OpenAI::Internal::Type::BaseModel
  341. # @!attribute id
  342. # The unique ID of the local shell call.
  343. #
  344. # @return [String]
  345. 1 required :id, String
  346. # @!attribute action
  347. # Execute a shell command on the server.
  348. #
  349. # @return [OpenAI::Models::Responses::ResponseInputItem::LocalShellCall::Action]
  350. 1 required :action, -> { OpenAI::Responses::ResponseInputItem::LocalShellCall::Action }
  351. # @!attribute call_id
  352. # The unique ID of the local shell tool call generated by the model.
  353. #
  354. # @return [String]
  355. 1 required :call_id, String
  356. # @!attribute status
  357. # The status of the local shell call.
  358. #
  359. # @return [Symbol, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall::Status]
  360. 1 required :status, enum: -> { OpenAI::Responses::ResponseInputItem::LocalShellCall::Status }
  361. # @!attribute type
  362. # The type of the local shell call. Always `local_shell_call`.
  363. #
  364. # @return [Symbol, :local_shell_call]
  365. 1 required :type, const: :local_shell_call
  366. # @!method initialize(id:, action:, call_id:, status:, type: :local_shell_call)
  367. # Some parameter documentations has been truncated, see
  368. # {OpenAI::Models::Responses::ResponseInputItem::LocalShellCall} for more details.
  369. #
  370. # A tool call to run a command on the local shell.
  371. #
  372. # @param id [String] The unique ID of the local shell call.
  373. #
  374. # @param action [OpenAI::Models::Responses::ResponseInputItem::LocalShellCall::Action] Execute a shell command on the server.
  375. #
  376. # @param call_id [String] The unique ID of the local shell tool call generated by the model.
  377. #
  378. # @param status [Symbol, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall::Status] The status of the local shell call.
  379. #
  380. # @param type [Symbol, :local_shell_call] The type of the local shell call. Always `local_shell_call`.
  381. # @see OpenAI::Models::Responses::ResponseInputItem::LocalShellCall#action
  382. 1 class Action < OpenAI::Internal::Type::BaseModel
  383. # @!attribute command
  384. # The command to run.
  385. #
  386. # @return [Array<String>]
  387. 1 required :command, OpenAI::Internal::Type::ArrayOf[String]
  388. # @!attribute env
  389. # Environment variables to set for the command.
  390. #
  391. # @return [Hash{Symbol=>String}]
  392. 1 required :env, OpenAI::Internal::Type::HashOf[String]
  393. # @!attribute type
  394. # The type of the local shell action. Always `exec`.
  395. #
  396. # @return [Symbol, :exec]
  397. 1 required :type, const: :exec
  398. # @!attribute timeout_ms
  399. # Optional timeout in milliseconds for the command.
  400. #
  401. # @return [Integer, nil]
  402. 1 optional :timeout_ms, Integer, nil?: true
  403. # @!attribute user
  404. # Optional user to run the command as.
  405. #
  406. # @return [String, nil]
  407. 1 optional :user, String, nil?: true
  408. # @!attribute working_directory
  409. # Optional working directory to run the command in.
  410. #
  411. # @return [String, nil]
  412. 1 optional :working_directory, String, nil?: true
  413. # @!method initialize(command:, env:, timeout_ms: nil, user: nil, working_directory: nil, type: :exec)
  414. # Some parameter documentations has been truncated, see
  415. # {OpenAI::Models::Responses::ResponseInputItem::LocalShellCall::Action} for more
  416. # details.
  417. #
  418. # Execute a shell command on the server.
  419. #
  420. # @param command [Array<String>] The command to run.
  421. #
  422. # @param env [Hash{Symbol=>String}] Environment variables to set for the command.
  423. #
  424. # @param timeout_ms [Integer, nil] Optional timeout in milliseconds for the command.
  425. #
  426. # @param user [String, nil] Optional user to run the command as.
  427. #
  428. # @param working_directory [String, nil] Optional working directory to run the command in.
  429. #
  430. # @param type [Symbol, :exec] The type of the local shell action. Always `exec`.
  431. end
  432. # The status of the local shell call.
  433. #
  434. # @see OpenAI::Models::Responses::ResponseInputItem::LocalShellCall#status
  435. 1 module Status
  436. 1 extend OpenAI::Internal::Type::Enum
  437. 1 IN_PROGRESS = :in_progress
  438. 1 COMPLETED = :completed
  439. 1 INCOMPLETE = :incomplete
  440. # @!method self.values
  441. # @return [Array<Symbol>]
  442. end
  443. end
  444. 1 class LocalShellCallOutput < OpenAI::Internal::Type::BaseModel
  445. # @!attribute id
  446. # The unique ID of the local shell tool call generated by the model.
  447. #
  448. # @return [String]
  449. 1 required :id, String
  450. # @!attribute output
  451. # A JSON string of the output of the local shell tool call.
  452. #
  453. # @return [String]
  454. 1 required :output, String
  455. # @!attribute type
  456. # The type of the local shell tool call output. Always `local_shell_call_output`.
  457. #
  458. # @return [Symbol, :local_shell_call_output]
  459. 1 required :type, const: :local_shell_call_output
  460. # @!attribute status
  461. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  462. #
  463. # @return [Symbol, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput::Status, nil]
  464. 1 optional :status,
  465. enum: -> { OpenAI::Responses::ResponseInputItem::LocalShellCallOutput::Status },
  466. nil?: true
  467. # @!method initialize(id:, output:, status: nil, type: :local_shell_call_output)
  468. # Some parameter documentations has been truncated, see
  469. # {OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput} for more
  470. # details.
  471. #
  472. # The output of a local shell tool call.
  473. #
  474. # @param id [String] The unique ID of the local shell tool call generated by the model.
  475. #
  476. # @param output [String] A JSON string of the output of the local shell tool call.
  477. #
  478. # @param status [Symbol, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput::Status, nil] The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  479. #
  480. # @param type [Symbol, :local_shell_call_output] The type of the local shell tool call output. Always `local_shell_call_output`.
  481. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  482. #
  483. # @see OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput#status
  484. 1 module Status
  485. 1 extend OpenAI::Internal::Type::Enum
  486. 1 IN_PROGRESS = :in_progress
  487. 1 COMPLETED = :completed
  488. 1 INCOMPLETE = :incomplete
  489. # @!method self.values
  490. # @return [Array<Symbol>]
  491. end
  492. end
  493. 1 class McpListTools < OpenAI::Internal::Type::BaseModel
  494. # @!attribute id
  495. # The unique ID of the list.
  496. #
  497. # @return [String]
  498. 1 required :id, String
  499. # @!attribute server_label
  500. # The label of the MCP server.
  501. #
  502. # @return [String]
  503. 1 required :server_label, String
  504. # @!attribute tools
  505. # The tools available on the server.
  506. #
  507. # @return [Array<OpenAI::Models::Responses::ResponseInputItem::McpListTools::Tool>]
  508. 1 required :tools,
  509. -> {
  510. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseInputItem::McpListTools::Tool]
  511. }
  512. # @!attribute type
  513. # The type of the item. Always `mcp_list_tools`.
  514. #
  515. # @return [Symbol, :mcp_list_tools]
  516. 1 required :type, const: :mcp_list_tools
  517. # @!attribute error
  518. # Error message if the server could not list tools.
  519. #
  520. # @return [String, nil]
  521. 1 optional :error, String, nil?: true
  522. # @!method initialize(id:, server_label:, tools:, error: nil, type: :mcp_list_tools)
  523. # Some parameter documentations has been truncated, see
  524. # {OpenAI::Models::Responses::ResponseInputItem::McpListTools} for more details.
  525. #
  526. # A list of tools available on an MCP server.
  527. #
  528. # @param id [String] The unique ID of the list.
  529. #
  530. # @param server_label [String] The label of the MCP server.
  531. #
  532. # @param tools [Array<OpenAI::Models::Responses::ResponseInputItem::McpListTools::Tool>] The tools available on the server.
  533. #
  534. # @param error [String, nil] Error message if the server could not list tools.
  535. #
  536. # @param type [Symbol, :mcp_list_tools] The type of the item. Always `mcp_list_tools`.
  537. 1 class Tool < OpenAI::Internal::Type::BaseModel
  538. # @!attribute input_schema
  539. # The JSON schema describing the tool's input.
  540. #
  541. # @return [Object]
  542. 1 required :input_schema, OpenAI::Internal::Type::Unknown
  543. # @!attribute name
  544. # The name of the tool.
  545. #
  546. # @return [String]
  547. 1 required :name, String
  548. # @!attribute annotations
  549. # Additional annotations about the tool.
  550. #
  551. # @return [Object, nil]
  552. 1 optional :annotations, OpenAI::Internal::Type::Unknown, nil?: true
  553. # @!attribute description
  554. # The description of the tool.
  555. #
  556. # @return [String, nil]
  557. 1 optional :description, String, nil?: true
  558. # @!method initialize(input_schema:, name:, annotations: nil, description: nil)
  559. # Some parameter documentations has been truncated, see
  560. # {OpenAI::Models::Responses::ResponseInputItem::McpListTools::Tool} for more
  561. # details.
  562. #
  563. # A tool available on an MCP server.
  564. #
  565. # @param input_schema [Object] The JSON schema describing the tool's input.
  566. #
  567. # @param name [String] The name of the tool.
  568. #
  569. # @param annotations [Object, nil] Additional annotations about the tool.
  570. #
  571. # @param description [String, nil] The description of the tool.
  572. end
  573. end
  574. 1 class McpApprovalRequest < OpenAI::Internal::Type::BaseModel
  575. # @!attribute id
  576. # The unique ID of the approval request.
  577. #
  578. # @return [String]
  579. 1 required :id, String
  580. # @!attribute arguments
  581. # A JSON string of arguments for the tool.
  582. #
  583. # @return [String]
  584. 1 required :arguments, String
  585. # @!attribute name
  586. # The name of the tool to run.
  587. #
  588. # @return [String]
  589. 1 required :name, String
  590. # @!attribute server_label
  591. # The label of the MCP server making the request.
  592. #
  593. # @return [String]
  594. 1 required :server_label, String
  595. # @!attribute type
  596. # The type of the item. Always `mcp_approval_request`.
  597. #
  598. # @return [Symbol, :mcp_approval_request]
  599. 1 required :type, const: :mcp_approval_request
  600. # @!method initialize(id:, arguments:, name:, server_label:, type: :mcp_approval_request)
  601. # Some parameter documentations has been truncated, see
  602. # {OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest} for more
  603. # details.
  604. #
  605. # A request for human approval of a tool invocation.
  606. #
  607. # @param id [String] The unique ID of the approval request.
  608. #
  609. # @param arguments [String] A JSON string of arguments for the tool.
  610. #
  611. # @param name [String] The name of the tool to run.
  612. #
  613. # @param server_label [String] The label of the MCP server making the request.
  614. #
  615. # @param type [Symbol, :mcp_approval_request] The type of the item. Always `mcp_approval_request`.
  616. end
  617. 1 class McpApprovalResponse < OpenAI::Internal::Type::BaseModel
  618. # @!attribute approval_request_id
  619. # The ID of the approval request being answered.
  620. #
  621. # @return [String]
  622. 1 required :approval_request_id, String
  623. # @!attribute approve
  624. # Whether the request was approved.
  625. #
  626. # @return [Boolean]
  627. 1 required :approve, OpenAI::Internal::Type::Boolean
  628. # @!attribute type
  629. # The type of the item. Always `mcp_approval_response`.
  630. #
  631. # @return [Symbol, :mcp_approval_response]
  632. 1 required :type, const: :mcp_approval_response
  633. # @!attribute id
  634. # The unique ID of the approval response
  635. #
  636. # @return [String, nil]
  637. 1 optional :id, String, nil?: true
  638. # @!attribute reason
  639. # Optional reason for the decision.
  640. #
  641. # @return [String, nil]
  642. 1 optional :reason, String, nil?: true
  643. # @!method initialize(approval_request_id:, approve:, id: nil, reason: nil, type: :mcp_approval_response)
  644. # Some parameter documentations has been truncated, see
  645. # {OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse} for more
  646. # details.
  647. #
  648. # A response to an MCP approval request.
  649. #
  650. # @param approval_request_id [String] The ID of the approval request being answered.
  651. #
  652. # @param approve [Boolean] Whether the request was approved.
  653. #
  654. # @param id [String, nil] The unique ID of the approval response
  655. #
  656. # @param reason [String, nil] Optional reason for the decision.
  657. #
  658. # @param type [Symbol, :mcp_approval_response] The type of the item. Always `mcp_approval_response`.
  659. end
  660. 1 class McpCall < OpenAI::Internal::Type::BaseModel
  661. # @!attribute id
  662. # The unique ID of the tool call.
  663. #
  664. # @return [String]
  665. 1 required :id, String
  666. # @!attribute arguments
  667. # A JSON string of the arguments passed to the tool.
  668. #
  669. # @return [String]
  670. 1 required :arguments, String
  671. # @!attribute name
  672. # The name of the tool that was run.
  673. #
  674. # @return [String]
  675. 1 required :name, String
  676. # @!attribute server_label
  677. # The label of the MCP server running the tool.
  678. #
  679. # @return [String]
  680. 1 required :server_label, String
  681. # @!attribute type
  682. # The type of the item. Always `mcp_call`.
  683. #
  684. # @return [Symbol, :mcp_call]
  685. 1 required :type, const: :mcp_call
  686. # @!attribute error
  687. # The error from the tool call, if any.
  688. #
  689. # @return [String, nil]
  690. 1 optional :error, String, nil?: true
  691. # @!attribute output
  692. # The output from the tool call.
  693. #
  694. # @return [String, nil]
  695. 1 optional :output, String, nil?: true
  696. # @!method initialize(id:, arguments:, name:, server_label:, error: nil, output: nil, type: :mcp_call)
  697. # Some parameter documentations has been truncated, see
  698. # {OpenAI::Models::Responses::ResponseInputItem::McpCall} for more details.
  699. #
  700. # An invocation of a tool on an MCP server.
  701. #
  702. # @param id [String] The unique ID of the tool call.
  703. #
  704. # @param arguments [String] A JSON string of the arguments passed to the tool.
  705. #
  706. # @param name [String] The name of the tool that was run.
  707. #
  708. # @param server_label [String] The label of the MCP server running the tool.
  709. #
  710. # @param error [String, nil] The error from the tool call, if any.
  711. #
  712. # @param output [String, nil] The output from the tool call.
  713. #
  714. # @param type [Symbol, :mcp_call] The type of the item. Always `mcp_call`.
  715. end
  716. 1 class ItemReference < OpenAI::Internal::Type::BaseModel
  717. # @!attribute id
  718. # The ID of the item to reference.
  719. #
  720. # @return [String]
  721. 1 required :id, String
  722. # @!attribute type
  723. # The type of item to reference. Always `item_reference`.
  724. #
  725. # @return [Symbol, OpenAI::Models::Responses::ResponseInputItem::ItemReference::Type, nil]
  726. 1 optional :type, enum: -> { OpenAI::Responses::ResponseInputItem::ItemReference::Type }, nil?: true
  727. # @!method initialize(id:, type: nil)
  728. # An internal identifier for an item to reference.
  729. #
  730. # @param id [String] The ID of the item to reference.
  731. #
  732. # @param type [Symbol, OpenAI::Models::Responses::ResponseInputItem::ItemReference::Type, nil] The type of item to reference. Always `item_reference`.
  733. # The type of item to reference. Always `item_reference`.
  734. #
  735. # @see OpenAI::Models::Responses::ResponseInputItem::ItemReference#type
  736. 1 module Type
  737. 1 extend OpenAI::Internal::Type::Enum
  738. 1 ITEM_REFERENCE = :item_reference
  739. # @!method self.values
  740. # @return [Array<Symbol>]
  741. end
  742. end
  743. # @!method self.variants
  744. # @return [Array(OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference)]
  745. end
  746. end
  747. end
  748. end

openai-ruby/lib/openai/models/responses/response_input_message_content_list.rb

100.0% lines covered

100.0% branches covered

4 relevant lines. 4 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # @type [OpenAI::Internal::Type::Converter]
  6. ResponseInputMessageContentList =
  7. 1 OpenAI::Internal::Type::ArrayOf[union: -> { OpenAI::Responses::ResponseInputContent }]
  8. end
  9. end
  10. end

openai-ruby/lib/openai/models/responses/response_input_message_item.rb

95.65% lines covered

100.0% branches covered

23 relevant lines. 22 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseInputMessageItem < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the message input.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute content
  12. # A list of one or many input items to the model, containing different content
  13. # types.
  14. #
  15. # @return [Array<OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile>]
  16. 1 required :content,
  17. -> {
  18. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::ResponseInputContent]
  19. }
  20. # @!attribute role
  21. # The role of the message input. One of `user`, `system`, or `developer`.
  22. #
  23. # @return [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Role]
  24. 1 required :role, enum: -> { OpenAI::Responses::ResponseInputMessageItem::Role }
  25. # @!attribute status
  26. # The status of item. One of `in_progress`, `completed`, or `incomplete`.
  27. # Populated when items are returned via API.
  28. #
  29. # @return [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Status, nil]
  30. 1 optional :status, enum: -> { OpenAI::Responses::ResponseInputMessageItem::Status }
  31. # @!attribute type
  32. # The type of the message input. Always set to `message`.
  33. #
  34. # @return [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Type, nil]
  35. 1 optional :type, enum: -> { OpenAI::Responses::ResponseInputMessageItem::Type }
  36. # @!method initialize(id:, content:, role:, status: nil, type: nil)
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseInputMessageItem} for more details.
  39. #
  40. # @param id [String] The unique ID of the message input.
  41. #
  42. # @param content [Array<OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile>] A list of one or many input items to the model, containing different content
  43. #
  44. # @param role [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Role] The role of the message input. One of `user`, `system`, or `developer`.
  45. #
  46. # @param status [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Status] The status of item. One of `in_progress`, `completed`, or
  47. #
  48. # @param type [Symbol, OpenAI::Models::Responses::ResponseInputMessageItem::Type] The type of the message input. Always set to `message`.
  49. # The role of the message input. One of `user`, `system`, or `developer`.
  50. #
  51. # @see OpenAI::Models::Responses::ResponseInputMessageItem#role
  52. 1 module Role
  53. 1 extend OpenAI::Internal::Type::Enum
  54. 1 USER = :user
  55. 1 SYSTEM = :system
  56. 1 DEVELOPER = :developer
  57. # @!method self.values
  58. # @return [Array<Symbol>]
  59. end
  60. # The status of item. One of `in_progress`, `completed`, or `incomplete`.
  61. # Populated when items are returned via API.
  62. #
  63. # @see OpenAI::Models::Responses::ResponseInputMessageItem#status
  64. 1 module Status
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 IN_PROGRESS = :in_progress
  67. 1 COMPLETED = :completed
  68. 1 INCOMPLETE = :incomplete
  69. # @!method self.values
  70. # @return [Array<Symbol>]
  71. end
  72. # The type of the message input. Always set to `message`.
  73. #
  74. # @see OpenAI::Models::Responses::ResponseInputMessageItem#type
  75. 1 module Type
  76. 1 extend OpenAI::Internal::Type::Enum
  77. 1 MESSAGE = :message
  78. # @!method self.values
  79. # @return [Array<Symbol>]
  80. end
  81. end
  82. end
  83. end
  84. end

openai-ruby/lib/openai/models/responses/response_input_text.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseInputText < OpenAI::Internal::Type::BaseModel
  6. # @!attribute text
  7. # The text input to the model.
  8. #
  9. # @return [String]
  10. 1 required :text, String
  11. # @!attribute type
  12. # The type of the input item. Always `input_text`.
  13. #
  14. # @return [Symbol, :input_text]
  15. 1 required :type, const: :input_text
  16. # @!method initialize(text:, type: :input_text)
  17. # A text input to the model.
  18. #
  19. # @param text [String] The text input to the model.
  20. #
  21. # @param type [Symbol, :input_text] The type of the input item. Always `input_text`.
  22. end
  23. end
  24. end
  25. end

openai-ruby/lib/openai/models/responses/response_item.rb

97.87% lines covered

100.0% branches covered

94 relevant lines. 92 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # Content item used to generate a response.
  6. 1 module ResponseItem
  7. 1 extend OpenAI::Internal::Type::Union
  8. 1 discriminator :type
  9. 1 variant :message, -> { OpenAI::Responses::ResponseInputMessageItem }
  10. # An output message from the model.
  11. 1 variant :message, -> { OpenAI::Responses::ResponseOutputMessage }
  12. # The results of a file search tool call. See the
  13. # [file search guide](https://platform.openai.com/docs/guides/tools-file-search) for more information.
  14. 1 variant :file_search_call, -> { OpenAI::Responses::ResponseFileSearchToolCall }
  15. # A tool call to a computer use tool. See the
  16. # [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use) for more information.
  17. 1 variant :computer_call, -> { OpenAI::Responses::ResponseComputerToolCall }
  18. 1 variant :computer_call_output, -> { OpenAI::Responses::ResponseComputerToolCallOutputItem }
  19. # The results of a web search tool call. See the
  20. # [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for more information.
  21. 1 variant :web_search_call, -> { OpenAI::Responses::ResponseFunctionWebSearch }
  22. # A tool call to run a function. See the
  23. # [function calling guide](https://platform.openai.com/docs/guides/function-calling) for more information.
  24. 1 variant :function_call, -> { OpenAI::Responses::ResponseFunctionToolCallItem }
  25. 1 variant :function_call_output, -> { OpenAI::Responses::ResponseFunctionToolCallOutputItem }
  26. # An image generation request made by the model.
  27. 1 variant :image_generation_call, -> { OpenAI::Responses::ResponseItem::ImageGenerationCall }
  28. # A tool call to run code.
  29. 1 variant :code_interpreter_call, -> { OpenAI::Responses::ResponseCodeInterpreterToolCall }
  30. # A tool call to run a command on the local shell.
  31. 1 variant :local_shell_call, -> { OpenAI::Responses::ResponseItem::LocalShellCall }
  32. # The output of a local shell tool call.
  33. 1 variant :local_shell_call_output, -> { OpenAI::Responses::ResponseItem::LocalShellCallOutput }
  34. # A list of tools available on an MCP server.
  35. 1 variant :mcp_list_tools, -> { OpenAI::Responses::ResponseItem::McpListTools }
  36. # A request for human approval of a tool invocation.
  37. 1 variant :mcp_approval_request, -> { OpenAI::Responses::ResponseItem::McpApprovalRequest }
  38. # A response to an MCP approval request.
  39. 1 variant :mcp_approval_response, -> { OpenAI::Responses::ResponseItem::McpApprovalResponse }
  40. # An invocation of a tool on an MCP server.
  41. 1 variant :mcp_call, -> { OpenAI::Responses::ResponseItem::McpCall }
  42. 1 class ImageGenerationCall < OpenAI::Internal::Type::BaseModel
  43. # @!attribute id
  44. # The unique ID of the image generation call.
  45. #
  46. # @return [String]
  47. 1 required :id, String
  48. # @!attribute result
  49. # The generated image encoded in base64.
  50. #
  51. # @return [String, nil]
  52. 1 required :result, String, nil?: true
  53. # @!attribute status
  54. # The status of the image generation call.
  55. #
  56. # @return [Symbol, OpenAI::Models::Responses::ResponseItem::ImageGenerationCall::Status]
  57. 1 required :status, enum: -> { OpenAI::Responses::ResponseItem::ImageGenerationCall::Status }
  58. # @!attribute type
  59. # The type of the image generation call. Always `image_generation_call`.
  60. #
  61. # @return [Symbol, :image_generation_call]
  62. 1 required :type, const: :image_generation_call
  63. # @!method initialize(id:, result:, status:, type: :image_generation_call)
  64. # Some parameter documentations has been truncated, see
  65. # {OpenAI::Models::Responses::ResponseItem::ImageGenerationCall} for more details.
  66. #
  67. # An image generation request made by the model.
  68. #
  69. # @param id [String] The unique ID of the image generation call.
  70. #
  71. # @param result [String, nil] The generated image encoded in base64.
  72. #
  73. # @param status [Symbol, OpenAI::Models::Responses::ResponseItem::ImageGenerationCall::Status] The status of the image generation call.
  74. #
  75. # @param type [Symbol, :image_generation_call] The type of the image generation call. Always `image_generation_call`.
  76. # The status of the image generation call.
  77. #
  78. # @see OpenAI::Models::Responses::ResponseItem::ImageGenerationCall#status
  79. 1 module Status
  80. 1 extend OpenAI::Internal::Type::Enum
  81. 1 IN_PROGRESS = :in_progress
  82. 1 COMPLETED = :completed
  83. 1 GENERATING = :generating
  84. 1 FAILED = :failed
  85. # @!method self.values
  86. # @return [Array<Symbol>]
  87. end
  88. end
  89. 1 class LocalShellCall < OpenAI::Internal::Type::BaseModel
  90. # @!attribute id
  91. # The unique ID of the local shell call.
  92. #
  93. # @return [String]
  94. 1 required :id, String
  95. # @!attribute action
  96. # Execute a shell command on the server.
  97. #
  98. # @return [OpenAI::Models::Responses::ResponseItem::LocalShellCall::Action]
  99. 1 required :action, -> { OpenAI::Responses::ResponseItem::LocalShellCall::Action }
  100. # @!attribute call_id
  101. # The unique ID of the local shell tool call generated by the model.
  102. #
  103. # @return [String]
  104. 1 required :call_id, String
  105. # @!attribute status
  106. # The status of the local shell call.
  107. #
  108. # @return [Symbol, OpenAI::Models::Responses::ResponseItem::LocalShellCall::Status]
  109. 1 required :status, enum: -> { OpenAI::Responses::ResponseItem::LocalShellCall::Status }
  110. # @!attribute type
  111. # The type of the local shell call. Always `local_shell_call`.
  112. #
  113. # @return [Symbol, :local_shell_call]
  114. 1 required :type, const: :local_shell_call
  115. # @!method initialize(id:, action:, call_id:, status:, type: :local_shell_call)
  116. # Some parameter documentations has been truncated, see
  117. # {OpenAI::Models::Responses::ResponseItem::LocalShellCall} for more details.
  118. #
  119. # A tool call to run a command on the local shell.
  120. #
  121. # @param id [String] The unique ID of the local shell call.
  122. #
  123. # @param action [OpenAI::Models::Responses::ResponseItem::LocalShellCall::Action] Execute a shell command on the server.
  124. #
  125. # @param call_id [String] The unique ID of the local shell tool call generated by the model.
  126. #
  127. # @param status [Symbol, OpenAI::Models::Responses::ResponseItem::LocalShellCall::Status] The status of the local shell call.
  128. #
  129. # @param type [Symbol, :local_shell_call] The type of the local shell call. Always `local_shell_call`.
  130. # @see OpenAI::Models::Responses::ResponseItem::LocalShellCall#action
  131. 1 class Action < OpenAI::Internal::Type::BaseModel
  132. # @!attribute command
  133. # The command to run.
  134. #
  135. # @return [Array<String>]
  136. 1 required :command, OpenAI::Internal::Type::ArrayOf[String]
  137. # @!attribute env
  138. # Environment variables to set for the command.
  139. #
  140. # @return [Hash{Symbol=>String}]
  141. 1 required :env, OpenAI::Internal::Type::HashOf[String]
  142. # @!attribute type
  143. # The type of the local shell action. Always `exec`.
  144. #
  145. # @return [Symbol, :exec]
  146. 1 required :type, const: :exec
  147. # @!attribute timeout_ms
  148. # Optional timeout in milliseconds for the command.
  149. #
  150. # @return [Integer, nil]
  151. 1 optional :timeout_ms, Integer, nil?: true
  152. # @!attribute user
  153. # Optional user to run the command as.
  154. #
  155. # @return [String, nil]
  156. 1 optional :user, String, nil?: true
  157. # @!attribute working_directory
  158. # Optional working directory to run the command in.
  159. #
  160. # @return [String, nil]
  161. 1 optional :working_directory, String, nil?: true
  162. # @!method initialize(command:, env:, timeout_ms: nil, user: nil, working_directory: nil, type: :exec)
  163. # Some parameter documentations has been truncated, see
  164. # {OpenAI::Models::Responses::ResponseItem::LocalShellCall::Action} for more
  165. # details.
  166. #
  167. # Execute a shell command on the server.
  168. #
  169. # @param command [Array<String>] The command to run.
  170. #
  171. # @param env [Hash{Symbol=>String}] Environment variables to set for the command.
  172. #
  173. # @param timeout_ms [Integer, nil] Optional timeout in milliseconds for the command.
  174. #
  175. # @param user [String, nil] Optional user to run the command as.
  176. #
  177. # @param working_directory [String, nil] Optional working directory to run the command in.
  178. #
  179. # @param type [Symbol, :exec] The type of the local shell action. Always `exec`.
  180. end
  181. # The status of the local shell call.
  182. #
  183. # @see OpenAI::Models::Responses::ResponseItem::LocalShellCall#status
  184. 1 module Status
  185. 1 extend OpenAI::Internal::Type::Enum
  186. 1 IN_PROGRESS = :in_progress
  187. 1 COMPLETED = :completed
  188. 1 INCOMPLETE = :incomplete
  189. # @!method self.values
  190. # @return [Array<Symbol>]
  191. end
  192. end
  193. 1 class LocalShellCallOutput < OpenAI::Internal::Type::BaseModel
  194. # @!attribute id
  195. # The unique ID of the local shell tool call generated by the model.
  196. #
  197. # @return [String]
  198. 1 required :id, String
  199. # @!attribute output
  200. # A JSON string of the output of the local shell tool call.
  201. #
  202. # @return [String]
  203. 1 required :output, String
  204. # @!attribute type
  205. # The type of the local shell tool call output. Always `local_shell_call_output`.
  206. #
  207. # @return [Symbol, :local_shell_call_output]
  208. 1 required :type, const: :local_shell_call_output
  209. # @!attribute status
  210. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  211. #
  212. # @return [Symbol, OpenAI::Models::Responses::ResponseItem::LocalShellCallOutput::Status, nil]
  213. 1 optional :status,
  214. enum: -> {
  215. OpenAI::Responses::ResponseItem::LocalShellCallOutput::Status
  216. },
  217. nil?: true
  218. # @!method initialize(id:, output:, status: nil, type: :local_shell_call_output)
  219. # Some parameter documentations has been truncated, see
  220. # {OpenAI::Models::Responses::ResponseItem::LocalShellCallOutput} for more
  221. # details.
  222. #
  223. # The output of a local shell tool call.
  224. #
  225. # @param id [String] The unique ID of the local shell tool call generated by the model.
  226. #
  227. # @param output [String] A JSON string of the output of the local shell tool call.
  228. #
  229. # @param status [Symbol, OpenAI::Models::Responses::ResponseItem::LocalShellCallOutput::Status, nil] The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  230. #
  231. # @param type [Symbol, :local_shell_call_output] The type of the local shell tool call output. Always `local_shell_call_output`.
  232. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  233. #
  234. # @see OpenAI::Models::Responses::ResponseItem::LocalShellCallOutput#status
  235. 1 module Status
  236. 1 extend OpenAI::Internal::Type::Enum
  237. 1 IN_PROGRESS = :in_progress
  238. 1 COMPLETED = :completed
  239. 1 INCOMPLETE = :incomplete
  240. # @!method self.values
  241. # @return [Array<Symbol>]
  242. end
  243. end
  244. 1 class McpListTools < OpenAI::Internal::Type::BaseModel
  245. # @!attribute id
  246. # The unique ID of the list.
  247. #
  248. # @return [String]
  249. 1 required :id, String
  250. # @!attribute server_label
  251. # The label of the MCP server.
  252. #
  253. # @return [String]
  254. 1 required :server_label, String
  255. # @!attribute tools
  256. # The tools available on the server.
  257. #
  258. # @return [Array<OpenAI::Models::Responses::ResponseItem::McpListTools::Tool>]
  259. 1 required :tools,
  260. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseItem::McpListTools::Tool] }
  261. # @!attribute type
  262. # The type of the item. Always `mcp_list_tools`.
  263. #
  264. # @return [Symbol, :mcp_list_tools]
  265. 1 required :type, const: :mcp_list_tools
  266. # @!attribute error
  267. # Error message if the server could not list tools.
  268. #
  269. # @return [String, nil]
  270. 1 optional :error, String, nil?: true
  271. # @!method initialize(id:, server_label:, tools:, error: nil, type: :mcp_list_tools)
  272. # Some parameter documentations has been truncated, see
  273. # {OpenAI::Models::Responses::ResponseItem::McpListTools} for more details.
  274. #
  275. # A list of tools available on an MCP server.
  276. #
  277. # @param id [String] The unique ID of the list.
  278. #
  279. # @param server_label [String] The label of the MCP server.
  280. #
  281. # @param tools [Array<OpenAI::Models::Responses::ResponseItem::McpListTools::Tool>] The tools available on the server.
  282. #
  283. # @param error [String, nil] Error message if the server could not list tools.
  284. #
  285. # @param type [Symbol, :mcp_list_tools] The type of the item. Always `mcp_list_tools`.
  286. 1 class Tool < OpenAI::Internal::Type::BaseModel
  287. # @!attribute input_schema
  288. # The JSON schema describing the tool's input.
  289. #
  290. # @return [Object]
  291. 1 required :input_schema, OpenAI::Internal::Type::Unknown
  292. # @!attribute name
  293. # The name of the tool.
  294. #
  295. # @return [String]
  296. 1 required :name, String
  297. # @!attribute annotations
  298. # Additional annotations about the tool.
  299. #
  300. # @return [Object, nil]
  301. 1 optional :annotations, OpenAI::Internal::Type::Unknown, nil?: true
  302. # @!attribute description
  303. # The description of the tool.
  304. #
  305. # @return [String, nil]
  306. 1 optional :description, String, nil?: true
  307. # @!method initialize(input_schema:, name:, annotations: nil, description: nil)
  308. # Some parameter documentations has been truncated, see
  309. # {OpenAI::Models::Responses::ResponseItem::McpListTools::Tool} for more details.
  310. #
  311. # A tool available on an MCP server.
  312. #
  313. # @param input_schema [Object] The JSON schema describing the tool's input.
  314. #
  315. # @param name [String] The name of the tool.
  316. #
  317. # @param annotations [Object, nil] Additional annotations about the tool.
  318. #
  319. # @param description [String, nil] The description of the tool.
  320. end
  321. end
  322. 1 class McpApprovalRequest < OpenAI::Internal::Type::BaseModel
  323. # @!attribute id
  324. # The unique ID of the approval request.
  325. #
  326. # @return [String]
  327. 1 required :id, String
  328. # @!attribute arguments
  329. # A JSON string of arguments for the tool.
  330. #
  331. # @return [String]
  332. 1 required :arguments, String
  333. # @!attribute name
  334. # The name of the tool to run.
  335. #
  336. # @return [String]
  337. 1 required :name, String
  338. # @!attribute server_label
  339. # The label of the MCP server making the request.
  340. #
  341. # @return [String]
  342. 1 required :server_label, String
  343. # @!attribute type
  344. # The type of the item. Always `mcp_approval_request`.
  345. #
  346. # @return [Symbol, :mcp_approval_request]
  347. 1 required :type, const: :mcp_approval_request
  348. # @!method initialize(id:, arguments:, name:, server_label:, type: :mcp_approval_request)
  349. # Some parameter documentations has been truncated, see
  350. # {OpenAI::Models::Responses::ResponseItem::McpApprovalRequest} for more details.
  351. #
  352. # A request for human approval of a tool invocation.
  353. #
  354. # @param id [String] The unique ID of the approval request.
  355. #
  356. # @param arguments [String] A JSON string of arguments for the tool.
  357. #
  358. # @param name [String] The name of the tool to run.
  359. #
  360. # @param server_label [String] The label of the MCP server making the request.
  361. #
  362. # @param type [Symbol, :mcp_approval_request] The type of the item. Always `mcp_approval_request`.
  363. end
  364. 1 class McpApprovalResponse < OpenAI::Internal::Type::BaseModel
  365. # @!attribute id
  366. # The unique ID of the approval response
  367. #
  368. # @return [String]
  369. 1 required :id, String
  370. # @!attribute approval_request_id
  371. # The ID of the approval request being answered.
  372. #
  373. # @return [String]
  374. 1 required :approval_request_id, String
  375. # @!attribute approve
  376. # Whether the request was approved.
  377. #
  378. # @return [Boolean]
  379. 1 required :approve, OpenAI::Internal::Type::Boolean
  380. # @!attribute type
  381. # The type of the item. Always `mcp_approval_response`.
  382. #
  383. # @return [Symbol, :mcp_approval_response]
  384. 1 required :type, const: :mcp_approval_response
  385. # @!attribute reason
  386. # Optional reason for the decision.
  387. #
  388. # @return [String, nil]
  389. 1 optional :reason, String, nil?: true
  390. # @!method initialize(id:, approval_request_id:, approve:, reason: nil, type: :mcp_approval_response)
  391. # Some parameter documentations has been truncated, see
  392. # {OpenAI::Models::Responses::ResponseItem::McpApprovalResponse} for more details.
  393. #
  394. # A response to an MCP approval request.
  395. #
  396. # @param id [String] The unique ID of the approval response
  397. #
  398. # @param approval_request_id [String] The ID of the approval request being answered.
  399. #
  400. # @param approve [Boolean] Whether the request was approved.
  401. #
  402. # @param reason [String, nil] Optional reason for the decision.
  403. #
  404. # @param type [Symbol, :mcp_approval_response] The type of the item. Always `mcp_approval_response`.
  405. end
  406. 1 class McpCall < OpenAI::Internal::Type::BaseModel
  407. # @!attribute id
  408. # The unique ID of the tool call.
  409. #
  410. # @return [String]
  411. 1 required :id, String
  412. # @!attribute arguments
  413. # A JSON string of the arguments passed to the tool.
  414. #
  415. # @return [String]
  416. 1 required :arguments, String
  417. # @!attribute name
  418. # The name of the tool that was run.
  419. #
  420. # @return [String]
  421. 1 required :name, String
  422. # @!attribute server_label
  423. # The label of the MCP server running the tool.
  424. #
  425. # @return [String]
  426. 1 required :server_label, String
  427. # @!attribute type
  428. # The type of the item. Always `mcp_call`.
  429. #
  430. # @return [Symbol, :mcp_call]
  431. 1 required :type, const: :mcp_call
  432. # @!attribute error
  433. # The error from the tool call, if any.
  434. #
  435. # @return [String, nil]
  436. 1 optional :error, String, nil?: true
  437. # @!attribute output
  438. # The output from the tool call.
  439. #
  440. # @return [String, nil]
  441. 1 optional :output, String, nil?: true
  442. # @!method initialize(id:, arguments:, name:, server_label:, error: nil, output: nil, type: :mcp_call)
  443. # Some parameter documentations has been truncated, see
  444. # {OpenAI::Models::Responses::ResponseItem::McpCall} for more details.
  445. #
  446. # An invocation of a tool on an MCP server.
  447. #
  448. # @param id [String] The unique ID of the tool call.
  449. #
  450. # @param arguments [String] A JSON string of the arguments passed to the tool.
  451. #
  452. # @param name [String] The name of the tool that was run.
  453. #
  454. # @param server_label [String] The label of the MCP server running the tool.
  455. #
  456. # @param error [String, nil] The error from the tool call, if any.
  457. #
  458. # @param output [String, nil] The output from the tool call.
  459. #
  460. # @param type [Symbol, :mcp_call] The type of the item. Always `mcp_call`.
  461. end
  462. # @!method self.variants
  463. # @return [Array(OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCallItem, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem, OpenAI::Models::Responses::ResponseItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseItem::LocalShellCall, OpenAI::Models::Responses::ResponseItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseItem::McpListTools, OpenAI::Models::Responses::ResponseItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseItem::McpCall)]
  464. end
  465. end
  466. end
  467. end

openai-ruby/lib/openai/models/responses/response_item_list.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseItemList < OpenAI::Internal::Type::BaseModel
  6. # @!attribute data
  7. # A list of items used to generate this response.
  8. #
  9. # @return [Array<OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCallItem, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem, OpenAI::Models::Responses::ResponseItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseItem::LocalShellCall, OpenAI::Models::Responses::ResponseItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseItem::McpListTools, OpenAI::Models::Responses::ResponseItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseItem::McpCall>]
  10. 1 required :data, -> { OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::ResponseItem] }
  11. # @!attribute first_id
  12. # The ID of the first item in the list.
  13. #
  14. # @return [String]
  15. 1 required :first_id, String
  16. # @!attribute has_more
  17. # Whether there are more items available.
  18. #
  19. # @return [Boolean]
  20. 1 required :has_more, OpenAI::Internal::Type::Boolean
  21. # @!attribute last_id
  22. # The ID of the last item in the list.
  23. #
  24. # @return [String]
  25. 1 required :last_id, String
  26. # @!attribute object
  27. # The type of object returned, must be `list`.
  28. #
  29. # @return [Symbol, :list]
  30. 1 required :object, const: :list
  31. # @!method initialize(data:, first_id:, has_more:, last_id:, object: :list)
  32. # A list of Response items.
  33. #
  34. # @param data [Array<OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCallItem, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem, OpenAI::Models::Responses::ResponseItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseItem::LocalShellCall, OpenAI::Models::Responses::ResponseItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseItem::McpListTools, OpenAI::Models::Responses::ResponseItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseItem::McpCall>] A list of items used to generate this response.
  35. #
  36. # @param first_id [String] The ID of the first item in the list.
  37. #
  38. # @param has_more [Boolean] Whether there are more items available.
  39. #
  40. # @param last_id [String] The ID of the last item in the list.
  41. #
  42. # @param object [Symbol, :list] The type of object returned, must be `list`.
  43. end
  44. end
  45. 1 ResponseItemList = Responses::ResponseItemList
  46. end
  47. end

openai-ruby/lib/openai/models/responses/response_mcp_call_arguments_delta_event.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseMcpCallArgumentsDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute delta
  7. # A JSON string containing the partial update to the arguments for the MCP tool
  8. # call.
  9. #
  10. # @return [String]
  11. 1 required :delta, String
  12. # @!attribute item_id
  13. # The unique identifier of the MCP tool call item being processed.
  14. #
  15. # @return [String]
  16. 1 required :item_id, String
  17. # @!attribute output_index
  18. # The index of the output item in the response's output array.
  19. #
  20. # @return [Integer]
  21. 1 required :output_index, Integer
  22. # @!attribute sequence_number
  23. # The sequence number of this event.
  24. #
  25. # @return [Integer]
  26. 1 required :sequence_number, Integer
  27. # @!attribute type
  28. # The type of the event. Always 'response.mcp_call_arguments.delta'.
  29. #
  30. # @return [Symbol, :"response.mcp_call_arguments.delta"]
  31. 1 required :type, const: :"response.mcp_call_arguments.delta"
  32. # @!method initialize(delta:, item_id:, output_index:, sequence_number:, type: :"response.mcp_call_arguments.delta")
  33. # Some parameter documentations has been truncated, see
  34. # {OpenAI::Models::Responses::ResponseMcpCallArgumentsDeltaEvent} for more
  35. # details.
  36. #
  37. # Emitted when there is a delta (partial update) to the arguments of an MCP tool
  38. # call.
  39. #
  40. # @param delta [String] A JSON string containing the partial update to the arguments for the MCP tool ca
  41. #
  42. # @param item_id [String] The unique identifier of the MCP tool call item being processed.
  43. #
  44. # @param output_index [Integer] The index of the output item in the response's output array.
  45. #
  46. # @param sequence_number [Integer] The sequence number of this event.
  47. #
  48. # @param type [Symbol, :"response.mcp_call_arguments.delta"] The type of the event. Always 'response.mcp_call_arguments.delta'.
  49. end
  50. end
  51. end
  52. end

openai-ruby/lib/openai/models/responses/response_mcp_call_arguments_done_event.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseMcpCallArgumentsDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute arguments
  7. # A JSON string containing the finalized arguments for the MCP tool call.
  8. #
  9. # @return [String]
  10. 1 required :arguments, String
  11. # @!attribute item_id
  12. # The unique identifier of the MCP tool call item being processed.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute output_index
  17. # The index of the output item in the response's output array.
  18. #
  19. # @return [Integer]
  20. 1 required :output_index, Integer
  21. # @!attribute sequence_number
  22. # The sequence number of this event.
  23. #
  24. # @return [Integer]
  25. 1 required :sequence_number, Integer
  26. # @!attribute type
  27. # The type of the event. Always 'response.mcp_call_arguments.done'.
  28. #
  29. # @return [Symbol, :"response.mcp_call_arguments.done"]
  30. 1 required :type, const: :"response.mcp_call_arguments.done"
  31. # @!method initialize(arguments:, item_id:, output_index:, sequence_number:, type: :"response.mcp_call_arguments.done")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Responses::ResponseMcpCallArgumentsDoneEvent} for more details.
  34. #
  35. # Emitted when the arguments for an MCP tool call are finalized.
  36. #
  37. # @param arguments [String] A JSON string containing the finalized arguments for the MCP tool call.
  38. #
  39. # @param item_id [String] The unique identifier of the MCP tool call item being processed.
  40. #
  41. # @param output_index [Integer] The index of the output item in the response's output array.
  42. #
  43. # @param sequence_number [Integer] The sequence number of this event.
  44. #
  45. # @param type [Symbol, :"response.mcp_call_arguments.done"] The type of the event. Always 'response.mcp_call_arguments.done'.
  46. end
  47. end
  48. end
  49. end

openai-ruby/lib/openai/models/responses/response_mcp_call_completed_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseMcpCallCompletedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the MCP tool call item that completed.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that completed.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always 'response.mcp_call.completed'.
  23. #
  24. # @return [Symbol, :"response.mcp_call.completed"]
  25. 1 required :type, const: :"response.mcp_call.completed"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.mcp_call.completed")
  27. # Emitted when an MCP tool call has completed successfully.
  28. #
  29. # @param item_id [String] The ID of the MCP tool call item that completed.
  30. #
  31. # @param output_index [Integer] The index of the output item that completed.
  32. #
  33. # @param sequence_number [Integer] The sequence number of this event.
  34. #
  35. # @param type [Symbol, :"response.mcp_call.completed"] The type of the event. Always 'response.mcp_call.completed'.
  36. end
  37. end
  38. end
  39. end

openai-ruby/lib/openai/models/responses/response_mcp_call_failed_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseMcpCallFailedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the MCP tool call item that failed.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that failed.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always 'response.mcp_call.failed'.
  23. #
  24. # @return [Symbol, :"response.mcp_call.failed"]
  25. 1 required :type, const: :"response.mcp_call.failed"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.mcp_call.failed")
  27. # Emitted when an MCP tool call has failed.
  28. #
  29. # @param item_id [String] The ID of the MCP tool call item that failed.
  30. #
  31. # @param output_index [Integer] The index of the output item that failed.
  32. #
  33. # @param sequence_number [Integer] The sequence number of this event.
  34. #
  35. # @param type [Symbol, :"response.mcp_call.failed"] The type of the event. Always 'response.mcp_call.failed'.
  36. end
  37. end
  38. end
  39. end

openai-ruby/lib/openai/models/responses/response_mcp_call_in_progress_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseMcpCallInProgressEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The unique identifier of the MCP tool call item being processed.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item in the response's output array.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always 'response.mcp_call.in_progress'.
  23. #
  24. # @return [Symbol, :"response.mcp_call.in_progress"]
  25. 1 required :type, const: :"response.mcp_call.in_progress"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.mcp_call.in_progress")
  27. # Emitted when an MCP tool call is in progress.
  28. #
  29. # @param item_id [String] The unique identifier of the MCP tool call item being processed.
  30. #
  31. # @param output_index [Integer] The index of the output item in the response's output array.
  32. #
  33. # @param sequence_number [Integer] The sequence number of this event.
  34. #
  35. # @param type [Symbol, :"response.mcp_call.in_progress"] The type of the event. Always 'response.mcp_call.in_progress'.
  36. end
  37. end
  38. end
  39. end

openai-ruby/lib/openai/models/responses/response_mcp_list_tools_completed_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseMcpListToolsCompletedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the MCP tool call item that produced this output.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that was processed.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always 'response.mcp_list_tools.completed'.
  23. #
  24. # @return [Symbol, :"response.mcp_list_tools.completed"]
  25. 1 required :type, const: :"response.mcp_list_tools.completed"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.mcp_list_tools.completed")
  27. # Emitted when the list of available MCP tools has been successfully retrieved.
  28. #
  29. # @param item_id [String] The ID of the MCP tool call item that produced this output.
  30. #
  31. # @param output_index [Integer] The index of the output item that was processed.
  32. #
  33. # @param sequence_number [Integer] The sequence number of this event.
  34. #
  35. # @param type [Symbol, :"response.mcp_list_tools.completed"] The type of the event. Always 'response.mcp_list_tools.completed'.
  36. end
  37. end
  38. end
  39. end

openai-ruby/lib/openai/models/responses/response_mcp_list_tools_failed_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseMcpListToolsFailedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the MCP tool call item that failed.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that failed.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always 'response.mcp_list_tools.failed'.
  23. #
  24. # @return [Symbol, :"response.mcp_list_tools.failed"]
  25. 1 required :type, const: :"response.mcp_list_tools.failed"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.mcp_list_tools.failed")
  27. # Emitted when the attempt to list available MCP tools has failed.
  28. #
  29. # @param item_id [String] The ID of the MCP tool call item that failed.
  30. #
  31. # @param output_index [Integer] The index of the output item that failed.
  32. #
  33. # @param sequence_number [Integer] The sequence number of this event.
  34. #
  35. # @param type [Symbol, :"response.mcp_list_tools.failed"] The type of the event. Always 'response.mcp_list_tools.failed'.
  36. end
  37. end
  38. end
  39. end

openai-ruby/lib/openai/models/responses/response_mcp_list_tools_in_progress_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseMcpListToolsInProgressEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the MCP tool call item that is being processed.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that is being processed.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always 'response.mcp_list_tools.in_progress'.
  23. #
  24. # @return [Symbol, :"response.mcp_list_tools.in_progress"]
  25. 1 required :type, const: :"response.mcp_list_tools.in_progress"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.mcp_list_tools.in_progress")
  27. # Emitted when the system is in the process of retrieving the list of available
  28. # MCP tools.
  29. #
  30. # @param item_id [String] The ID of the MCP tool call item that is being processed.
  31. #
  32. # @param output_index [Integer] The index of the output item that is being processed.
  33. #
  34. # @param sequence_number [Integer] The sequence number of this event.
  35. #
  36. # @param type [Symbol, :"response.mcp_list_tools.in_progress"] The type of the event. Always 'response.mcp_list_tools.in_progress'.
  37. end
  38. end
  39. end
  40. end

openai-ruby/lib/openai/models/responses/response_output_audio.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseOutputAudio < OpenAI::Internal::Type::BaseModel
  6. # @!attribute data
  7. # Base64-encoded audio data from the model.
  8. #
  9. # @return [String]
  10. 1 required :data, String
  11. # @!attribute transcript
  12. # The transcript of the audio data from the model.
  13. #
  14. # @return [String]
  15. 1 required :transcript, String
  16. # @!attribute type
  17. # The type of the output audio. Always `output_audio`.
  18. #
  19. # @return [Symbol, :output_audio]
  20. 1 required :type, const: :output_audio
  21. # @!method initialize(data:, transcript:, type: :output_audio)
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ResponseOutputAudio} for more details.
  24. #
  25. # An audio output from the model.
  26. #
  27. # @param data [String] Base64-encoded audio data from the model.
  28. #
  29. # @param transcript [String] The transcript of the audio data from the model.
  30. #
  31. # @param type [Symbol, :output_audio] The type of the output audio. Always `output_audio`.
  32. end
  33. end
  34. end
  35. end

openai-ruby/lib/openai/models/responses/response_output_item.rb

98.63% lines covered

100.0% branches covered

73 relevant lines. 72 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # An output message from the model.
  6. 1 module ResponseOutputItem
  7. 1 extend OpenAI::Internal::Type::Union
  8. 1 discriminator :type
  9. # An output message from the model.
  10. 1 variant :message, -> { OpenAI::Responses::ResponseOutputMessage }
  11. # The results of a file search tool call. See the
  12. # [file search guide](https://platform.openai.com/docs/guides/tools-file-search) for more information.
  13. 1 variant :file_search_call, -> { OpenAI::Responses::ResponseFileSearchToolCall }
  14. # A tool call to run a function. See the
  15. # [function calling guide](https://platform.openai.com/docs/guides/function-calling) for more information.
  16. 1 variant :function_call, -> { OpenAI::Responses::ResponseFunctionToolCall }
  17. # The results of a web search tool call. See the
  18. # [web search guide](https://platform.openai.com/docs/guides/tools-web-search) for more information.
  19. 1 variant :web_search_call, -> { OpenAI::Responses::ResponseFunctionWebSearch }
  20. # A tool call to a computer use tool. See the
  21. # [computer use guide](https://platform.openai.com/docs/guides/tools-computer-use) for more information.
  22. 1 variant :computer_call, -> { OpenAI::Responses::ResponseComputerToolCall }
  23. # A description of the chain of thought used by a reasoning model while generating
  24. # a response. Be sure to include these items in your `input` to the Responses API
  25. # for subsequent turns of a conversation if you are manually
  26. # [managing context](https://platform.openai.com/docs/guides/conversation-state).
  27. 1 variant :reasoning, -> { OpenAI::Responses::ResponseReasoningItem }
  28. # An image generation request made by the model.
  29. 1 variant :image_generation_call, -> { OpenAI::Responses::ResponseOutputItem::ImageGenerationCall }
  30. # A tool call to run code.
  31. 1 variant :code_interpreter_call, -> { OpenAI::Responses::ResponseCodeInterpreterToolCall }
  32. # A tool call to run a command on the local shell.
  33. 1 variant :local_shell_call, -> { OpenAI::Responses::ResponseOutputItem::LocalShellCall }
  34. # An invocation of a tool on an MCP server.
  35. 1 variant :mcp_call, -> { OpenAI::Responses::ResponseOutputItem::McpCall }
  36. # A list of tools available on an MCP server.
  37. 1 variant :mcp_list_tools, -> { OpenAI::Responses::ResponseOutputItem::McpListTools }
  38. # A request for human approval of a tool invocation.
  39. 1 variant :mcp_approval_request, -> { OpenAI::Responses::ResponseOutputItem::McpApprovalRequest }
  40. 1 class ImageGenerationCall < OpenAI::Internal::Type::BaseModel
  41. # @!attribute id
  42. # The unique ID of the image generation call.
  43. #
  44. # @return [String]
  45. 1 required :id, String
  46. # @!attribute result
  47. # The generated image encoded in base64.
  48. #
  49. # @return [String, nil]
  50. 1 required :result, String, nil?: true
  51. # @!attribute status
  52. # The status of the image generation call.
  53. #
  54. # @return [Symbol, OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall::Status]
  55. 1 required :status, enum: -> { OpenAI::Responses::ResponseOutputItem::ImageGenerationCall::Status }
  56. # @!attribute type
  57. # The type of the image generation call. Always `image_generation_call`.
  58. #
  59. # @return [Symbol, :image_generation_call]
  60. 1 required :type, const: :image_generation_call
  61. # @!method initialize(id:, result:, status:, type: :image_generation_call)
  62. # Some parameter documentations has been truncated, see
  63. # {OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall} for more
  64. # details.
  65. #
  66. # An image generation request made by the model.
  67. #
  68. # @param id [String] The unique ID of the image generation call.
  69. #
  70. # @param result [String, nil] The generated image encoded in base64.
  71. #
  72. # @param status [Symbol, OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall::Status] The status of the image generation call.
  73. #
  74. # @param type [Symbol, :image_generation_call] The type of the image generation call. Always `image_generation_call`.
  75. # The status of the image generation call.
  76. #
  77. # @see OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall#status
  78. 1 module Status
  79. 1 extend OpenAI::Internal::Type::Enum
  80. 1 IN_PROGRESS = :in_progress
  81. 1 COMPLETED = :completed
  82. 1 GENERATING = :generating
  83. 1 FAILED = :failed
  84. # @!method self.values
  85. # @return [Array<Symbol>]
  86. end
  87. end
  88. 1 class LocalShellCall < OpenAI::Internal::Type::BaseModel
  89. # @!attribute id
  90. # The unique ID of the local shell call.
  91. #
  92. # @return [String]
  93. 1 required :id, String
  94. # @!attribute action
  95. # Execute a shell command on the server.
  96. #
  97. # @return [OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall::Action]
  98. 1 required :action, -> { OpenAI::Responses::ResponseOutputItem::LocalShellCall::Action }
  99. # @!attribute call_id
  100. # The unique ID of the local shell tool call generated by the model.
  101. #
  102. # @return [String]
  103. 1 required :call_id, String
  104. # @!attribute status
  105. # The status of the local shell call.
  106. #
  107. # @return [Symbol, OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall::Status]
  108. 1 required :status, enum: -> { OpenAI::Responses::ResponseOutputItem::LocalShellCall::Status }
  109. # @!attribute type
  110. # The type of the local shell call. Always `local_shell_call`.
  111. #
  112. # @return [Symbol, :local_shell_call]
  113. 1 required :type, const: :local_shell_call
  114. # @!method initialize(id:, action:, call_id:, status:, type: :local_shell_call)
  115. # Some parameter documentations has been truncated, see
  116. # {OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall} for more
  117. # details.
  118. #
  119. # A tool call to run a command on the local shell.
  120. #
  121. # @param id [String] The unique ID of the local shell call.
  122. #
  123. # @param action [OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall::Action] Execute a shell command on the server.
  124. #
  125. # @param call_id [String] The unique ID of the local shell tool call generated by the model.
  126. #
  127. # @param status [Symbol, OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall::Status] The status of the local shell call.
  128. #
  129. # @param type [Symbol, :local_shell_call] The type of the local shell call. Always `local_shell_call`.
  130. # @see OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall#action
  131. 1 class Action < OpenAI::Internal::Type::BaseModel
  132. # @!attribute command
  133. # The command to run.
  134. #
  135. # @return [Array<String>]
  136. 1 required :command, OpenAI::Internal::Type::ArrayOf[String]
  137. # @!attribute env
  138. # Environment variables to set for the command.
  139. #
  140. # @return [Hash{Symbol=>String}]
  141. 1 required :env, OpenAI::Internal::Type::HashOf[String]
  142. # @!attribute type
  143. # The type of the local shell action. Always `exec`.
  144. #
  145. # @return [Symbol, :exec]
  146. 1 required :type, const: :exec
  147. # @!attribute timeout_ms
  148. # Optional timeout in milliseconds for the command.
  149. #
  150. # @return [Integer, nil]
  151. 1 optional :timeout_ms, Integer, nil?: true
  152. # @!attribute user
  153. # Optional user to run the command as.
  154. #
  155. # @return [String, nil]
  156. 1 optional :user, String, nil?: true
  157. # @!attribute working_directory
  158. # Optional working directory to run the command in.
  159. #
  160. # @return [String, nil]
  161. 1 optional :working_directory, String, nil?: true
  162. # @!method initialize(command:, env:, timeout_ms: nil, user: nil, working_directory: nil, type: :exec)
  163. # Some parameter documentations has been truncated, see
  164. # {OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall::Action} for more
  165. # details.
  166. #
  167. # Execute a shell command on the server.
  168. #
  169. # @param command [Array<String>] The command to run.
  170. #
  171. # @param env [Hash{Symbol=>String}] Environment variables to set for the command.
  172. #
  173. # @param timeout_ms [Integer, nil] Optional timeout in milliseconds for the command.
  174. #
  175. # @param user [String, nil] Optional user to run the command as.
  176. #
  177. # @param working_directory [String, nil] Optional working directory to run the command in.
  178. #
  179. # @param type [Symbol, :exec] The type of the local shell action. Always `exec`.
  180. end
  181. # The status of the local shell call.
  182. #
  183. # @see OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall#status
  184. 1 module Status
  185. 1 extend OpenAI::Internal::Type::Enum
  186. 1 IN_PROGRESS = :in_progress
  187. 1 COMPLETED = :completed
  188. 1 INCOMPLETE = :incomplete
  189. # @!method self.values
  190. # @return [Array<Symbol>]
  191. end
  192. end
  193. 1 class McpCall < OpenAI::Internal::Type::BaseModel
  194. # @!attribute id
  195. # The unique ID of the tool call.
  196. #
  197. # @return [String]
  198. 1 required :id, String
  199. # @!attribute arguments
  200. # A JSON string of the arguments passed to the tool.
  201. #
  202. # @return [String]
  203. 1 required :arguments, String
  204. # @!attribute name
  205. # The name of the tool that was run.
  206. #
  207. # @return [String]
  208. 1 required :name, String
  209. # @!attribute server_label
  210. # The label of the MCP server running the tool.
  211. #
  212. # @return [String]
  213. 1 required :server_label, String
  214. # @!attribute type
  215. # The type of the item. Always `mcp_call`.
  216. #
  217. # @return [Symbol, :mcp_call]
  218. 1 required :type, const: :mcp_call
  219. # @!attribute error
  220. # The error from the tool call, if any.
  221. #
  222. # @return [String, nil]
  223. 1 optional :error, String, nil?: true
  224. # @!attribute output
  225. # The output from the tool call.
  226. #
  227. # @return [String, nil]
  228. 1 optional :output, String, nil?: true
  229. # @!method initialize(id:, arguments:, name:, server_label:, error: nil, output: nil, type: :mcp_call)
  230. # Some parameter documentations has been truncated, see
  231. # {OpenAI::Models::Responses::ResponseOutputItem::McpCall} for more details.
  232. #
  233. # An invocation of a tool on an MCP server.
  234. #
  235. # @param id [String] The unique ID of the tool call.
  236. #
  237. # @param arguments [String] A JSON string of the arguments passed to the tool.
  238. #
  239. # @param name [String] The name of the tool that was run.
  240. #
  241. # @param server_label [String] The label of the MCP server running the tool.
  242. #
  243. # @param error [String, nil] The error from the tool call, if any.
  244. #
  245. # @param output [String, nil] The output from the tool call.
  246. #
  247. # @param type [Symbol, :mcp_call] The type of the item. Always `mcp_call`.
  248. end
  249. 1 class McpListTools < OpenAI::Internal::Type::BaseModel
  250. # @!attribute id
  251. # The unique ID of the list.
  252. #
  253. # @return [String]
  254. 1 required :id, String
  255. # @!attribute server_label
  256. # The label of the MCP server.
  257. #
  258. # @return [String]
  259. 1 required :server_label, String
  260. # @!attribute tools
  261. # The tools available on the server.
  262. #
  263. # @return [Array<OpenAI::Models::Responses::ResponseOutputItem::McpListTools::Tool>]
  264. 1 required :tools,
  265. -> {
  266. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseOutputItem::McpListTools::Tool]
  267. }
  268. # @!attribute type
  269. # The type of the item. Always `mcp_list_tools`.
  270. #
  271. # @return [Symbol, :mcp_list_tools]
  272. 1 required :type, const: :mcp_list_tools
  273. # @!attribute error
  274. # Error message if the server could not list tools.
  275. #
  276. # @return [String, nil]
  277. 1 optional :error, String, nil?: true
  278. # @!method initialize(id:, server_label:, tools:, error: nil, type: :mcp_list_tools)
  279. # Some parameter documentations has been truncated, see
  280. # {OpenAI::Models::Responses::ResponseOutputItem::McpListTools} for more details.
  281. #
  282. # A list of tools available on an MCP server.
  283. #
  284. # @param id [String] The unique ID of the list.
  285. #
  286. # @param server_label [String] The label of the MCP server.
  287. #
  288. # @param tools [Array<OpenAI::Models::Responses::ResponseOutputItem::McpListTools::Tool>] The tools available on the server.
  289. #
  290. # @param error [String, nil] Error message if the server could not list tools.
  291. #
  292. # @param type [Symbol, :mcp_list_tools] The type of the item. Always `mcp_list_tools`.
  293. 1 class Tool < OpenAI::Internal::Type::BaseModel
  294. # @!attribute input_schema
  295. # The JSON schema describing the tool's input.
  296. #
  297. # @return [Object]
  298. 1 required :input_schema, OpenAI::Internal::Type::Unknown
  299. # @!attribute name
  300. # The name of the tool.
  301. #
  302. # @return [String]
  303. 1 required :name, String
  304. # @!attribute annotations
  305. # Additional annotations about the tool.
  306. #
  307. # @return [Object, nil]
  308. 1 optional :annotations, OpenAI::Internal::Type::Unknown, nil?: true
  309. # @!attribute description
  310. # The description of the tool.
  311. #
  312. # @return [String, nil]
  313. 1 optional :description, String, nil?: true
  314. # @!method initialize(input_schema:, name:, annotations: nil, description: nil)
  315. # Some parameter documentations has been truncated, see
  316. # {OpenAI::Models::Responses::ResponseOutputItem::McpListTools::Tool} for more
  317. # details.
  318. #
  319. # A tool available on an MCP server.
  320. #
  321. # @param input_schema [Object] The JSON schema describing the tool's input.
  322. #
  323. # @param name [String] The name of the tool.
  324. #
  325. # @param annotations [Object, nil] Additional annotations about the tool.
  326. #
  327. # @param description [String, nil] The description of the tool.
  328. end
  329. end
  330. 1 class McpApprovalRequest < OpenAI::Internal::Type::BaseModel
  331. # @!attribute id
  332. # The unique ID of the approval request.
  333. #
  334. # @return [String]
  335. 1 required :id, String
  336. # @!attribute arguments
  337. # A JSON string of arguments for the tool.
  338. #
  339. # @return [String]
  340. 1 required :arguments, String
  341. # @!attribute name
  342. # The name of the tool to run.
  343. #
  344. # @return [String]
  345. 1 required :name, String
  346. # @!attribute server_label
  347. # The label of the MCP server making the request.
  348. #
  349. # @return [String]
  350. 1 required :server_label, String
  351. # @!attribute type
  352. # The type of the item. Always `mcp_approval_request`.
  353. #
  354. # @return [Symbol, :mcp_approval_request]
  355. 1 required :type, const: :mcp_approval_request
  356. # @!method initialize(id:, arguments:, name:, server_label:, type: :mcp_approval_request)
  357. # Some parameter documentations has been truncated, see
  358. # {OpenAI::Models::Responses::ResponseOutputItem::McpApprovalRequest} for more
  359. # details.
  360. #
  361. # A request for human approval of a tool invocation.
  362. #
  363. # @param id [String] The unique ID of the approval request.
  364. #
  365. # @param arguments [String] A JSON string of arguments for the tool.
  366. #
  367. # @param name [String] The name of the tool to run.
  368. #
  369. # @param server_label [String] The label of the MCP server making the request.
  370. #
  371. # @param type [Symbol, :mcp_approval_request] The type of the item. Always `mcp_approval_request`.
  372. end
  373. # @!method self.variants
  374. # @return [Array(OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall, OpenAI::Models::Responses::ResponseOutputItem::McpCall, OpenAI::Models::Responses::ResponseOutputItem::McpListTools, OpenAI::Models::Responses::ResponseOutputItem::McpApprovalRequest)]
  375. end
  376. end
  377. end
  378. end

openai-ruby/lib/openai/models/responses/response_output_item_added_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseOutputItemAddedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item
  7. # The output item that was added.
  8. #
  9. # @return [OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall, OpenAI::Models::Responses::ResponseOutputItem::McpCall, OpenAI::Models::Responses::ResponseOutputItem::McpListTools, OpenAI::Models::Responses::ResponseOutputItem::McpApprovalRequest]
  10. 1 required :item, union: -> { OpenAI::Responses::ResponseOutputItem }
  11. # @!attribute output_index
  12. # The index of the output item that was added.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always `response.output_item.added`.
  23. #
  24. # @return [Symbol, :"response.output_item.added"]
  25. 1 required :type, const: :"response.output_item.added"
  26. # @!method initialize(item:, output_index:, sequence_number:, type: :"response.output_item.added")
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Responses::ResponseOutputItemAddedEvent} for more details.
  29. #
  30. # Emitted when a new output item is added.
  31. #
  32. # @param item [OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall, OpenAI::Models::Responses::ResponseOutputItem::McpCall, OpenAI::Models::Responses::ResponseOutputItem::McpListTools, OpenAI::Models::Responses::ResponseOutputItem::McpApprovalRequest] The output item that was added.
  33. #
  34. # @param output_index [Integer] The index of the output item that was added.
  35. #
  36. # @param sequence_number [Integer] The sequence number of this event.
  37. #
  38. # @param type [Symbol, :"response.output_item.added"] The type of the event. Always `response.output_item.added`.
  39. end
  40. end
  41. end
  42. end

openai-ruby/lib/openai/models/responses/response_output_item_done_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseOutputItemDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item
  7. # The output item that was marked done.
  8. #
  9. # @return [OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall, OpenAI::Models::Responses::ResponseOutputItem::McpCall, OpenAI::Models::Responses::ResponseOutputItem::McpListTools, OpenAI::Models::Responses::ResponseOutputItem::McpApprovalRequest]
  10. 1 required :item, union: -> { OpenAI::Responses::ResponseOutputItem }
  11. # @!attribute output_index
  12. # The index of the output item that was marked done.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always `response.output_item.done`.
  23. #
  24. # @return [Symbol, :"response.output_item.done"]
  25. 1 required :type, const: :"response.output_item.done"
  26. # @!method initialize(item:, output_index:, sequence_number:, type: :"response.output_item.done")
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Responses::ResponseOutputItemDoneEvent} for more details.
  29. #
  30. # Emitted when an output item is marked done.
  31. #
  32. # @param item [OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseOutputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseOutputItem::LocalShellCall, OpenAI::Models::Responses::ResponseOutputItem::McpCall, OpenAI::Models::Responses::ResponseOutputItem::McpListTools, OpenAI::Models::Responses::ResponseOutputItem::McpApprovalRequest] The output item that was marked done.
  33. #
  34. # @param output_index [Integer] The index of the output item that was marked done.
  35. #
  36. # @param sequence_number [Integer] The sequence number of this event.
  37. #
  38. # @param type [Symbol, :"response.output_item.done"] The type of the event. Always `response.output_item.done`.
  39. end
  40. end
  41. end
  42. end

openai-ruby/lib/openai/models/responses/response_output_message.rb

95.0% lines covered

100.0% branches covered

20 relevant lines. 19 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseOutputMessage < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the output message.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute content
  12. # The content of the output message.
  13. #
  14. # @return [Array<OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal>]
  15. 1 required :content,
  16. -> {
  17. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::ResponseOutputMessage::Content]
  18. }
  19. # @!attribute role
  20. # The role of the output message. Always `assistant`.
  21. #
  22. # @return [Symbol, :assistant]
  23. 1 required :role, const: :assistant
  24. # @!attribute status
  25. # The status of the message input. One of `in_progress`, `completed`, or
  26. # `incomplete`. Populated when input items are returned via API.
  27. #
  28. # @return [Symbol, OpenAI::Models::Responses::ResponseOutputMessage::Status]
  29. 1 required :status, enum: -> { OpenAI::Responses::ResponseOutputMessage::Status }
  30. # @!attribute type
  31. # The type of the output message. Always `message`.
  32. #
  33. # @return [Symbol, :message]
  34. 1 required :type, const: :message
  35. # @!method initialize(id:, content:, status:, role: :assistant, type: :message)
  36. # Some parameter documentations has been truncated, see
  37. # {OpenAI::Models::Responses::ResponseOutputMessage} for more details.
  38. #
  39. # An output message from the model.
  40. #
  41. # @param id [String] The unique ID of the output message.
  42. #
  43. # @param content [Array<OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal>] The content of the output message.
  44. #
  45. # @param status [Symbol, OpenAI::Models::Responses::ResponseOutputMessage::Status] The status of the message input. One of `in_progress`, `completed`, or
  46. #
  47. # @param role [Symbol, :assistant] The role of the output message. Always `assistant`.
  48. #
  49. # @param type [Symbol, :message] The type of the output message. Always `message`.
  50. # A text output from the model.
  51. 1 module Content
  52. 1 extend OpenAI::Internal::Type::Union
  53. 1 discriminator :type
  54. # A text output from the model.
  55. 1 variant :output_text, -> { OpenAI::Responses::ResponseOutputText }
  56. # A refusal from the model.
  57. 1 variant :refusal, -> { OpenAI::Responses::ResponseOutputRefusal }
  58. # @!method self.variants
  59. # @return [Array(OpenAI::Models::Responses::ResponseOutputText, OpenAI::Models::Responses::ResponseOutputRefusal)]
  60. end
  61. # The status of the message input. One of `in_progress`, `completed`, or
  62. # `incomplete`. Populated when input items are returned via API.
  63. #
  64. # @see OpenAI::Models::Responses::ResponseOutputMessage#status
  65. 1 module Status
  66. 1 extend OpenAI::Internal::Type::Enum
  67. 1 IN_PROGRESS = :in_progress
  68. 1 COMPLETED = :completed
  69. 1 INCOMPLETE = :incomplete
  70. # @!method self.values
  71. # @return [Array<Symbol>]
  72. end
  73. end
  74. end
  75. end
  76. end

openai-ruby/lib/openai/models/responses/response_output_refusal.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseOutputRefusal < OpenAI::Internal::Type::BaseModel
  6. # @!attribute refusal
  7. # The refusal explanation from the model.
  8. #
  9. # @return [String]
  10. 1 required :refusal, String
  11. # @!attribute type
  12. # The type of the refusal. Always `refusal`.
  13. #
  14. # @return [Symbol, :refusal]
  15. 1 required :type, const: :refusal
  16. # @!method initialize(refusal:, type: :refusal)
  17. # A refusal from the model.
  18. #
  19. # @param refusal [String] The refusal explanation from the model.
  20. #
  21. # @param type [Symbol, :refusal] The type of the refusal. Always `refusal`.
  22. end
  23. end
  24. end
  25. end

openai-ruby/lib/openai/models/responses/response_output_text.rb

92.16% lines covered

100.0% branches covered

51 relevant lines. 47 lines covered and 4 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseOutputText < OpenAI::Internal::Type::BaseModel
  6. # @!attribute annotations
  7. # The annotations of the text output.
  8. #
  9. # @return [Array<OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::ContainerFileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath>]
  10. 1 required :annotations,
  11. -> {
  12. OpenAI::Internal::Type::ArrayOf[union: OpenAI::Responses::ResponseOutputText::Annotation]
  13. }
  14. # @!attribute text
  15. # The text output from the model.
  16. #
  17. # @return [String]
  18. 1 required :text, String
  19. # @!attribute parsed
  20. # The parsed contents of the output, if JSON schema is specified.
  21. #
  22. # @return [Object, nil]
  23. 1 optional :parsed, OpenAI::StructuredOutput::ParsedJson
  24. # @!attribute type
  25. # The type of the output text. Always `output_text`.
  26. #
  27. # @return [Symbol, :output_text]
  28. 1 required :type, const: :output_text
  29. # @!attribute logprobs
  30. #
  31. # @return [Array<OpenAI::Models::Responses::ResponseOutputText::Logprob>, nil]
  32. 1 optional :logprobs,
  33. -> {
  34. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseOutputText::Logprob]
  35. }
  36. # @!method initialize(annotations:, text:, logprobs: nil, type: :output_text)
  37. # A text output from the model.
  38. #
  39. # @param annotations [Array<OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::ContainerFileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath>] The annotations of the text output.
  40. #
  41. # @param text [String] The text output from the model.
  42. #
  43. # @param logprobs [Array<OpenAI::Models::Responses::ResponseOutputText::Logprob>]
  44. #
  45. # @param type [Symbol, :output_text] The type of the output text. Always `output_text`.
  46. # A citation to a file.
  47. 1 module Annotation
  48. 1 extend OpenAI::Internal::Type::Union
  49. 1 discriminator :type
  50. # A citation to a file.
  51. 1 variant :file_citation, -> { OpenAI::Responses::ResponseOutputText::Annotation::FileCitation }
  52. # A citation for a web resource used to generate a model response.
  53. 1 variant :url_citation, -> { OpenAI::Responses::ResponseOutputText::Annotation::URLCitation }
  54. # A citation for a container file used to generate a model response.
  55. 1 variant :container_file_citation,
  56. -> { OpenAI::Responses::ResponseOutputText::Annotation::ContainerFileCitation }
  57. # A path to a file.
  58. 1 variant :file_path, -> { OpenAI::Responses::ResponseOutputText::Annotation::FilePath }
  59. 1 class FileCitation < OpenAI::Internal::Type::BaseModel
  60. # @!attribute file_id
  61. # The ID of the file.
  62. #
  63. # @return [String]
  64. 1 required :file_id, String
  65. # @!attribute filename
  66. # The filename of the file cited.
  67. #
  68. # @return [String]
  69. 1 required :filename, String
  70. # @!attribute index
  71. # The index of the file in the list of files.
  72. #
  73. # @return [Integer]
  74. 1 required :index, Integer
  75. # @!attribute type
  76. # The type of the file citation. Always `file_citation`.
  77. #
  78. # @return [Symbol, :file_citation]
  79. 1 required :type, const: :file_citation
  80. # @!method initialize(file_id:, filename:, index:, type: :file_citation)
  81. # A citation to a file.
  82. #
  83. # @param file_id [String] The ID of the file.
  84. #
  85. # @param filename [String] The filename of the file cited.
  86. #
  87. # @param index [Integer] The index of the file in the list of files.
  88. #
  89. # @param type [Symbol, :file_citation] The type of the file citation. Always `file_citation`.
  90. end
  91. 1 class URLCitation < OpenAI::Internal::Type::BaseModel
  92. # @!attribute end_index
  93. # The index of the last character of the URL citation in the message.
  94. #
  95. # @return [Integer]
  96. 1 required :end_index, Integer
  97. # @!attribute start_index
  98. # The index of the first character of the URL citation in the message.
  99. #
  100. # @return [Integer]
  101. 1 required :start_index, Integer
  102. # @!attribute title
  103. # The title of the web resource.
  104. #
  105. # @return [String]
  106. 1 required :title, String
  107. # @!attribute type
  108. # The type of the URL citation. Always `url_citation`.
  109. #
  110. # @return [Symbol, :url_citation]
  111. 1 required :type, const: :url_citation
  112. # @!attribute url
  113. # The URL of the web resource.
  114. #
  115. # @return [String]
  116. 1 required :url, String
  117. # @!method initialize(end_index:, start_index:, title:, url:, type: :url_citation)
  118. # A citation for a web resource used to generate a model response.
  119. #
  120. # @param end_index [Integer] The index of the last character of the URL citation in the message.
  121. #
  122. # @param start_index [Integer] The index of the first character of the URL citation in the message.
  123. #
  124. # @param title [String] The title of the web resource.
  125. #
  126. # @param url [String] The URL of the web resource.
  127. #
  128. # @param type [Symbol, :url_citation] The type of the URL citation. Always `url_citation`.
  129. end
  130. 1 class ContainerFileCitation < OpenAI::Internal::Type::BaseModel
  131. # @!attribute container_id
  132. # The ID of the container file.
  133. #
  134. # @return [String]
  135. 1 required :container_id, String
  136. # @!attribute end_index
  137. # The index of the last character of the container file citation in the message.
  138. #
  139. # @return [Integer]
  140. 1 required :end_index, Integer
  141. # @!attribute file_id
  142. # The ID of the file.
  143. #
  144. # @return [String]
  145. 1 required :file_id, String
  146. # @!attribute filename
  147. # The filename of the container file cited.
  148. #
  149. # @return [String]
  150. 1 required :filename, String
  151. # @!attribute start_index
  152. # The index of the first character of the container file citation in the message.
  153. #
  154. # @return [Integer]
  155. 1 required :start_index, Integer
  156. # @!attribute type
  157. # The type of the container file citation. Always `container_file_citation`.
  158. #
  159. # @return [Symbol, :container_file_citation]
  160. 1 required :type, const: :container_file_citation
  161. # @!method initialize(container_id:, end_index:, file_id:, filename:, start_index:, type: :container_file_citation)
  162. # A citation for a container file used to generate a model response.
  163. #
  164. # @param container_id [String] The ID of the container file.
  165. #
  166. # @param end_index [Integer] The index of the last character of the container file citation in the message.
  167. #
  168. # @param file_id [String] The ID of the file.
  169. #
  170. # @param filename [String] The filename of the container file cited.
  171. #
  172. # @param start_index [Integer] The index of the first character of the container file citation in the message.
  173. #
  174. # @param type [Symbol, :container_file_citation] The type of the container file citation. Always `container_file_citation`.
  175. end
  176. 1 class FilePath < OpenAI::Internal::Type::BaseModel
  177. # @!attribute file_id
  178. # The ID of the file.
  179. #
  180. # @return [String]
  181. 1 required :file_id, String
  182. # @!attribute index
  183. # The index of the file in the list of files.
  184. #
  185. # @return [Integer]
  186. 1 required :index, Integer
  187. # @!attribute type
  188. # The type of the file path. Always `file_path`.
  189. #
  190. # @return [Symbol, :file_path]
  191. 1 required :type, const: :file_path
  192. # @!method initialize(file_id:, index:, type: :file_path)
  193. # Some parameter documentations has been truncated, see
  194. # {OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath} for more
  195. # details.
  196. #
  197. # A path to a file.
  198. #
  199. # @param file_id [String] The ID of the file.
  200. #
  201. # @param index [Integer] The index of the file in the list of files.
  202. #
  203. # @param type [Symbol, :file_path] The type of the file path. Always `file_path`.
  204. end
  205. # @!method self.variants
  206. # @return [Array(OpenAI::Models::Responses::ResponseOutputText::Annotation::FileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::URLCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::ContainerFileCitation, OpenAI::Models::Responses::ResponseOutputText::Annotation::FilePath)]
  207. end
  208. 1 class Logprob < OpenAI::Internal::Type::BaseModel
  209. # @!attribute token
  210. #
  211. # @return [String]
  212. 1 required :token, String
  213. # @!attribute bytes
  214. #
  215. # @return [Array<Integer>]
  216. 1 required :bytes, OpenAI::Internal::Type::ArrayOf[Integer]
  217. # @!attribute logprob
  218. #
  219. # @return [Float]
  220. 1 required :logprob, Float
  221. # @!attribute top_logprobs
  222. #
  223. # @return [Array<OpenAI::Models::Responses::ResponseOutputText::Logprob::TopLogprob>]
  224. 1 required :top_logprobs,
  225. -> {
  226. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseOutputText::Logprob::TopLogprob]
  227. }
  228. # @!method initialize(token:, bytes:, logprob:, top_logprobs:)
  229. # The log probability of a token.
  230. #
  231. # @param token [String]
  232. # @param bytes [Array<Integer>]
  233. # @param logprob [Float]
  234. # @param top_logprobs [Array<OpenAI::Models::Responses::ResponseOutputText::Logprob::TopLogprob>]
  235. 1 class TopLogprob < OpenAI::Internal::Type::BaseModel
  236. # @!attribute token
  237. #
  238. # @return [String]
  239. 1 required :token, String
  240. # @!attribute bytes
  241. #
  242. # @return [Array<Integer>]
  243. 1 required :bytes, OpenAI::Internal::Type::ArrayOf[Integer]
  244. # @!attribute logprob
  245. #
  246. # @return [Float]
  247. 1 required :logprob, Float
  248. # @!method initialize(token:, bytes:, logprob:)
  249. # The top log probability of a token.
  250. #
  251. # @param token [String]
  252. # @param bytes [Array<Integer>]
  253. # @param logprob [Float]
  254. end
  255. end
  256. end
  257. end
  258. end
  259. end

openai-ruby/lib/openai/models/responses/response_output_text_annotation_added_event.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseOutputTextAnnotationAddedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute annotation
  7. # The annotation object being added. (See annotation schema for details.)
  8. #
  9. # @return [Object]
  10. 1 required :annotation, OpenAI::Internal::Type::Unknown
  11. # @!attribute annotation_index
  12. # The index of the annotation within the content part.
  13. #
  14. # @return [Integer]
  15. 1 required :annotation_index, Integer
  16. # @!attribute content_index
  17. # The index of the content part within the output item.
  18. #
  19. # @return [Integer]
  20. 1 required :content_index, Integer
  21. # @!attribute item_id
  22. # The unique identifier of the item to which the annotation is being added.
  23. #
  24. # @return [String]
  25. 1 required :item_id, String
  26. # @!attribute output_index
  27. # The index of the output item in the response's output array.
  28. #
  29. # @return [Integer]
  30. 1 required :output_index, Integer
  31. # @!attribute sequence_number
  32. # The sequence number of this event.
  33. #
  34. # @return [Integer]
  35. 1 required :sequence_number, Integer
  36. # @!attribute type
  37. # The type of the event. Always 'response.output_text.annotation.added'.
  38. #
  39. # @return [Symbol, :"response.output_text.annotation.added"]
  40. 1 required :type, const: :"response.output_text.annotation.added"
  41. # @!method initialize(annotation:, annotation_index:, content_index:, item_id:, output_index:, sequence_number:, type: :"response.output_text.annotation.added")
  42. # Emitted when an annotation is added to output text content.
  43. #
  44. # @param annotation [Object] The annotation object being added. (See annotation schema for details.)
  45. #
  46. # @param annotation_index [Integer] The index of the annotation within the content part.
  47. #
  48. # @param content_index [Integer] The index of the content part within the output item.
  49. #
  50. # @param item_id [String] The unique identifier of the item to which the annotation is being added.
  51. #
  52. # @param output_index [Integer] The index of the output item in the response's output array.
  53. #
  54. # @param sequence_number [Integer] The sequence number of this event.
  55. #
  56. # @param type [Symbol, :"response.output_text.annotation.added"] The type of the event. Always 'response.output_text.annotation.added'.
  57. end
  58. end
  59. end
  60. end

openai-ruby/lib/openai/models/responses/response_prompt.rb

92.86% lines covered

100.0% branches covered

14 relevant lines. 13 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponsePrompt < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique identifier of the prompt template to use.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute variables
  12. # Optional map of values to substitute in for variables in your prompt. The
  13. # substitution values can either be strings, or other Response input types like
  14. # images or files.
  15. #
  16. # @return [Hash{Symbol=>String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile}, nil]
  17. 1 optional :variables,
  18. -> { OpenAI::Internal::Type::HashOf[union: OpenAI::Responses::ResponsePrompt::Variable] },
  19. nil?: true
  20. # @!attribute version
  21. # Optional version of the prompt template.
  22. #
  23. # @return [String, nil]
  24. 1 optional :version, String, nil?: true
  25. # @!method initialize(id:, variables: nil, version: nil)
  26. # Some parameter documentations has been truncated, see
  27. # {OpenAI::Models::Responses::ResponsePrompt} for more details.
  28. #
  29. # Reference to a prompt template and its variables.
  30. # [Learn more](https://platform.openai.com/docs/guides/text?api-mode=responses#reusable-prompts).
  31. #
  32. # @param id [String] The unique identifier of the prompt template to use.
  33. #
  34. # @param variables [Hash{Symbol=>String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile}, nil] Optional map of values to substitute in for variables in your
  35. #
  36. # @param version [String, nil] Optional version of the prompt template.
  37. # A text input to the model.
  38. 1 module Variable
  39. 1 extend OpenAI::Internal::Type::Union
  40. 1 variant String
  41. # A text input to the model.
  42. 1 variant -> { OpenAI::Responses::ResponseInputText }
  43. # An image input to the model. Learn about [image inputs](https://platform.openai.com/docs/guides/vision).
  44. 1 variant -> { OpenAI::Responses::ResponseInputImage }
  45. # A file input to the model.
  46. 1 variant -> { OpenAI::Responses::ResponseInputFile }
  47. # @!method self.variants
  48. # @return [Array(String, OpenAI::Models::Responses::ResponseInputText, OpenAI::Models::Responses::ResponseInputImage, OpenAI::Models::Responses::ResponseInputFile)]
  49. end
  50. end
  51. end
  52. end
  53. end

openai-ruby/lib/openai/models/responses/response_queued_event.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseQueuedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute response
  7. # The full response object that is queued.
  8. #
  9. # @return [OpenAI::Models::Responses::Response]
  10. 1 required :response, -> { OpenAI::Responses::Response }
  11. # @!attribute sequence_number
  12. # The sequence number for this event.
  13. #
  14. # @return [Integer]
  15. 1 required :sequence_number, Integer
  16. # @!attribute type
  17. # The type of the event. Always 'response.queued'.
  18. #
  19. # @return [Symbol, :"response.queued"]
  20. 1 required :type, const: :"response.queued"
  21. # @!method initialize(response:, sequence_number:, type: :"response.queued")
  22. # Emitted when a response is queued and waiting to be processed.
  23. #
  24. # @param response [OpenAI::Models::Responses::Response] The full response object that is queued.
  25. #
  26. # @param sequence_number [Integer] The sequence number for this event.
  27. #
  28. # @param type [Symbol, :"response.queued"] The type of the event. Always 'response.queued'.
  29. end
  30. end
  31. end
  32. end

openai-ruby/lib/openai/models/responses/response_reasoning_item.rb

94.44% lines covered

100.0% branches covered

18 relevant lines. 17 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseReasoningItem < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique identifier of the reasoning content.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute summary
  12. # Reasoning text contents.
  13. #
  14. # @return [Array<OpenAI::Models::Responses::ResponseReasoningItem::Summary>]
  15. 1 required :summary,
  16. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseReasoningItem::Summary] }
  17. # @!attribute type
  18. # The type of the object. Always `reasoning`.
  19. #
  20. # @return [Symbol, :reasoning]
  21. 1 required :type, const: :reasoning
  22. # @!attribute encrypted_content
  23. # The encrypted content of the reasoning item - populated when a response is
  24. # generated with `reasoning.encrypted_content` in the `include` parameter.
  25. #
  26. # @return [String, nil]
  27. 1 optional :encrypted_content, String, nil?: true
  28. # @!attribute status
  29. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  30. # Populated when items are returned via API.
  31. #
  32. # @return [Symbol, OpenAI::Models::Responses::ResponseReasoningItem::Status, nil]
  33. 1 optional :status, enum: -> { OpenAI::Responses::ResponseReasoningItem::Status }
  34. # @!method initialize(id:, summary:, encrypted_content: nil, status: nil, type: :reasoning)
  35. # Some parameter documentations has been truncated, see
  36. # {OpenAI::Models::Responses::ResponseReasoningItem} for more details.
  37. #
  38. # A description of the chain of thought used by a reasoning model while generating
  39. # a response. Be sure to include these items in your `input` to the Responses API
  40. # for subsequent turns of a conversation if you are manually
  41. # [managing context](https://platform.openai.com/docs/guides/conversation-state).
  42. #
  43. # @param id [String] The unique identifier of the reasoning content.
  44. #
  45. # @param summary [Array<OpenAI::Models::Responses::ResponseReasoningItem::Summary>] Reasoning text contents.
  46. #
  47. # @param encrypted_content [String, nil] The encrypted content of the reasoning item - populated when a response is
  48. #
  49. # @param status [Symbol, OpenAI::Models::Responses::ResponseReasoningItem::Status] The status of the item. One of `in_progress`, `completed`, or
  50. #
  51. # @param type [Symbol, :reasoning] The type of the object. Always `reasoning`.
  52. 1 class Summary < OpenAI::Internal::Type::BaseModel
  53. # @!attribute text
  54. # A short summary of the reasoning used by the model when generating the response.
  55. #
  56. # @return [String]
  57. 1 required :text, String
  58. # @!attribute type
  59. # The type of the object. Always `summary_text`.
  60. #
  61. # @return [Symbol, :summary_text]
  62. 1 required :type, const: :summary_text
  63. # @!method initialize(text:, type: :summary_text)
  64. # Some parameter documentations has been truncated, see
  65. # {OpenAI::Models::Responses::ResponseReasoningItem::Summary} for more details.
  66. #
  67. # @param text [String] A short summary of the reasoning used by the model when generating
  68. #
  69. # @param type [Symbol, :summary_text] The type of the object. Always `summary_text`.
  70. end
  71. # The status of the item. One of `in_progress`, `completed`, or `incomplete`.
  72. # Populated when items are returned via API.
  73. #
  74. # @see OpenAI::Models::Responses::ResponseReasoningItem#status
  75. 1 module Status
  76. 1 extend OpenAI::Internal::Type::Enum
  77. 1 IN_PROGRESS = :in_progress
  78. 1 COMPLETED = :completed
  79. 1 INCOMPLETE = :incomplete
  80. # @!method self.values
  81. # @return [Array<Symbol>]
  82. end
  83. end
  84. end
  85. end
  86. end

openai-ruby/lib/openai/models/responses/response_reasoning_summary_delta_event.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseReasoningSummaryDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute delta
  7. # The partial update to the reasoning summary content.
  8. #
  9. # @return [Object]
  10. 1 required :delta, OpenAI::Internal::Type::Unknown
  11. # @!attribute item_id
  12. # The unique identifier of the item for which the reasoning summary is being
  13. # updated.
  14. #
  15. # @return [String]
  16. 1 required :item_id, String
  17. # @!attribute output_index
  18. # The index of the output item in the response's output array.
  19. #
  20. # @return [Integer]
  21. 1 required :output_index, Integer
  22. # @!attribute sequence_number
  23. # The sequence number of this event.
  24. #
  25. # @return [Integer]
  26. 1 required :sequence_number, Integer
  27. # @!attribute summary_index
  28. # The index of the summary part within the output item.
  29. #
  30. # @return [Integer]
  31. 1 required :summary_index, Integer
  32. # @!attribute type
  33. # The type of the event. Always 'response.reasoning_summary.delta'.
  34. #
  35. # @return [Symbol, :"response.reasoning_summary.delta"]
  36. 1 required :type, const: :"response.reasoning_summary.delta"
  37. # @!method initialize(delta:, item_id:, output_index:, sequence_number:, summary_index:, type: :"response.reasoning_summary.delta")
  38. # Some parameter documentations has been truncated, see
  39. # {OpenAI::Models::Responses::ResponseReasoningSummaryDeltaEvent} for more
  40. # details.
  41. #
  42. # Emitted when there is a delta (partial update) to the reasoning summary content.
  43. #
  44. # @param delta [Object] The partial update to the reasoning summary content.
  45. #
  46. # @param item_id [String] The unique identifier of the item for which the reasoning summary is being updat
  47. #
  48. # @param output_index [Integer] The index of the output item in the response's output array.
  49. #
  50. # @param sequence_number [Integer] The sequence number of this event.
  51. #
  52. # @param summary_index [Integer] The index of the summary part within the output item.
  53. #
  54. # @param type [Symbol, :"response.reasoning_summary.delta"] The type of the event. Always 'response.reasoning_summary.delta'.
  55. end
  56. end
  57. end
  58. end

openai-ruby/lib/openai/models/responses/response_reasoning_summary_done_event.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseReasoningSummaryDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The unique identifier of the item for which the reasoning summary is finalized.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item in the response's output array.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute summary_index
  22. # The index of the summary part within the output item.
  23. #
  24. # @return [Integer]
  25. 1 required :summary_index, Integer
  26. # @!attribute text
  27. # The finalized reasoning summary text.
  28. #
  29. # @return [String]
  30. 1 required :text, String
  31. # @!attribute type
  32. # The type of the event. Always 'response.reasoning_summary.done'.
  33. #
  34. # @return [Symbol, :"response.reasoning_summary.done"]
  35. 1 required :type, const: :"response.reasoning_summary.done"
  36. # @!method initialize(item_id:, output_index:, sequence_number:, summary_index:, text:, type: :"response.reasoning_summary.done")
  37. # Emitted when the reasoning summary content is finalized for an item.
  38. #
  39. # @param item_id [String] The unique identifier of the item for which the reasoning summary is finalized.
  40. #
  41. # @param output_index [Integer] The index of the output item in the response's output array.
  42. #
  43. # @param sequence_number [Integer] The sequence number of this event.
  44. #
  45. # @param summary_index [Integer] The index of the summary part within the output item.
  46. #
  47. # @param text [String] The finalized reasoning summary text.
  48. #
  49. # @param type [Symbol, :"response.reasoning_summary.done"] The type of the event. Always 'response.reasoning_summary.done'.
  50. end
  51. end
  52. end
  53. end

openai-ruby/lib/openai/models/responses/response_reasoning_summary_part_added_event.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseReasoningSummaryPartAddedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the item this summary part is associated with.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item this summary part is associated with.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute part
  17. # The summary part that was added.
  18. #
  19. # @return [OpenAI::Models::Responses::ResponseReasoningSummaryPartAddedEvent::Part]
  20. 1 required :part, -> { OpenAI::Responses::ResponseReasoningSummaryPartAddedEvent::Part }
  21. # @!attribute sequence_number
  22. # The sequence number of this event.
  23. #
  24. # @return [Integer]
  25. 1 required :sequence_number, Integer
  26. # @!attribute summary_index
  27. # The index of the summary part within the reasoning summary.
  28. #
  29. # @return [Integer]
  30. 1 required :summary_index, Integer
  31. # @!attribute type
  32. # The type of the event. Always `response.reasoning_summary_part.added`.
  33. #
  34. # @return [Symbol, :"response.reasoning_summary_part.added"]
  35. 1 required :type, const: :"response.reasoning_summary_part.added"
  36. # @!method initialize(item_id:, output_index:, part:, sequence_number:, summary_index:, type: :"response.reasoning_summary_part.added")
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseReasoningSummaryPartAddedEvent} for more
  39. # details.
  40. #
  41. # Emitted when a new reasoning summary part is added.
  42. #
  43. # @param item_id [String] The ID of the item this summary part is associated with.
  44. #
  45. # @param output_index [Integer] The index of the output item this summary part is associated with.
  46. #
  47. # @param part [OpenAI::Models::Responses::ResponseReasoningSummaryPartAddedEvent::Part] The summary part that was added.
  48. #
  49. # @param sequence_number [Integer] The sequence number of this event.
  50. #
  51. # @param summary_index [Integer] The index of the summary part within the reasoning summary.
  52. #
  53. # @param type [Symbol, :"response.reasoning_summary_part.added"] The type of the event. Always `response.reasoning_summary_part.added`.
  54. # @see OpenAI::Models::Responses::ResponseReasoningSummaryPartAddedEvent#part
  55. 1 class Part < OpenAI::Internal::Type::BaseModel
  56. # @!attribute text
  57. # The text of the summary part.
  58. #
  59. # @return [String]
  60. 1 required :text, String
  61. # @!attribute type
  62. # The type of the summary part. Always `summary_text`.
  63. #
  64. # @return [Symbol, :summary_text]
  65. 1 required :type, const: :summary_text
  66. # @!method initialize(text:, type: :summary_text)
  67. # The summary part that was added.
  68. #
  69. # @param text [String] The text of the summary part.
  70. #
  71. # @param type [Symbol, :summary_text] The type of the summary part. Always `summary_text`.
  72. end
  73. end
  74. end
  75. end
  76. end

openai-ruby/lib/openai/models/responses/response_reasoning_summary_part_done_event.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseReasoningSummaryPartDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the item this summary part is associated with.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item this summary part is associated with.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute part
  17. # The completed summary part.
  18. #
  19. # @return [OpenAI::Models::Responses::ResponseReasoningSummaryPartDoneEvent::Part]
  20. 1 required :part, -> { OpenAI::Responses::ResponseReasoningSummaryPartDoneEvent::Part }
  21. # @!attribute sequence_number
  22. # The sequence number of this event.
  23. #
  24. # @return [Integer]
  25. 1 required :sequence_number, Integer
  26. # @!attribute summary_index
  27. # The index of the summary part within the reasoning summary.
  28. #
  29. # @return [Integer]
  30. 1 required :summary_index, Integer
  31. # @!attribute type
  32. # The type of the event. Always `response.reasoning_summary_part.done`.
  33. #
  34. # @return [Symbol, :"response.reasoning_summary_part.done"]
  35. 1 required :type, const: :"response.reasoning_summary_part.done"
  36. # @!method initialize(item_id:, output_index:, part:, sequence_number:, summary_index:, type: :"response.reasoning_summary_part.done")
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseReasoningSummaryPartDoneEvent} for more
  39. # details.
  40. #
  41. # Emitted when a reasoning summary part is completed.
  42. #
  43. # @param item_id [String] The ID of the item this summary part is associated with.
  44. #
  45. # @param output_index [Integer] The index of the output item this summary part is associated with.
  46. #
  47. # @param part [OpenAI::Models::Responses::ResponseReasoningSummaryPartDoneEvent::Part] The completed summary part.
  48. #
  49. # @param sequence_number [Integer] The sequence number of this event.
  50. #
  51. # @param summary_index [Integer] The index of the summary part within the reasoning summary.
  52. #
  53. # @param type [Symbol, :"response.reasoning_summary_part.done"] The type of the event. Always `response.reasoning_summary_part.done`.
  54. # @see OpenAI::Models::Responses::ResponseReasoningSummaryPartDoneEvent#part
  55. 1 class Part < OpenAI::Internal::Type::BaseModel
  56. # @!attribute text
  57. # The text of the summary part.
  58. #
  59. # @return [String]
  60. 1 required :text, String
  61. # @!attribute type
  62. # The type of the summary part. Always `summary_text`.
  63. #
  64. # @return [Symbol, :summary_text]
  65. 1 required :type, const: :summary_text
  66. # @!method initialize(text:, type: :summary_text)
  67. # The completed summary part.
  68. #
  69. # @param text [String] The text of the summary part.
  70. #
  71. # @param type [Symbol, :summary_text] The type of the summary part. Always `summary_text`.
  72. end
  73. end
  74. end
  75. end
  76. end

openai-ruby/lib/openai/models/responses/response_reasoning_summary_text_delta_event.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseReasoningSummaryTextDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute delta
  7. # The text delta that was added to the summary.
  8. #
  9. # @return [String]
  10. 1 required :delta, String
  11. # @!attribute item_id
  12. # The ID of the item this summary text delta is associated with.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute output_index
  17. # The index of the output item this summary text delta is associated with.
  18. #
  19. # @return [Integer]
  20. 1 required :output_index, Integer
  21. # @!attribute sequence_number
  22. # The sequence number of this event.
  23. #
  24. # @return [Integer]
  25. 1 required :sequence_number, Integer
  26. # @!attribute summary_index
  27. # The index of the summary part within the reasoning summary.
  28. #
  29. # @return [Integer]
  30. 1 required :summary_index, Integer
  31. # @!attribute type
  32. # The type of the event. Always `response.reasoning_summary_text.delta`.
  33. #
  34. # @return [Symbol, :"response.reasoning_summary_text.delta"]
  35. 1 required :type, const: :"response.reasoning_summary_text.delta"
  36. # @!method initialize(delta:, item_id:, output_index:, sequence_number:, summary_index:, type: :"response.reasoning_summary_text.delta")
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseReasoningSummaryTextDeltaEvent} for more
  39. # details.
  40. #
  41. # Emitted when a delta is added to a reasoning summary text.
  42. #
  43. # @param delta [String] The text delta that was added to the summary.
  44. #
  45. # @param item_id [String] The ID of the item this summary text delta is associated with.
  46. #
  47. # @param output_index [Integer] The index of the output item this summary text delta is associated with.
  48. #
  49. # @param sequence_number [Integer] The sequence number of this event.
  50. #
  51. # @param summary_index [Integer] The index of the summary part within the reasoning summary.
  52. #
  53. # @param type [Symbol, :"response.reasoning_summary_text.delta"] The type of the event. Always `response.reasoning_summary_text.delta`.
  54. end
  55. end
  56. end
  57. end

openai-ruby/lib/openai/models/responses/response_reasoning_summary_text_done_event.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseReasoningSummaryTextDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # The ID of the item this summary text is associated with.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item this summary text is associated with.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of this event.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute summary_index
  22. # The index of the summary part within the reasoning summary.
  23. #
  24. # @return [Integer]
  25. 1 required :summary_index, Integer
  26. # @!attribute text
  27. # The full text of the completed reasoning summary.
  28. #
  29. # @return [String]
  30. 1 required :text, String
  31. # @!attribute type
  32. # The type of the event. Always `response.reasoning_summary_text.done`.
  33. #
  34. # @return [Symbol, :"response.reasoning_summary_text.done"]
  35. 1 required :type, const: :"response.reasoning_summary_text.done"
  36. # @!method initialize(item_id:, output_index:, sequence_number:, summary_index:, text:, type: :"response.reasoning_summary_text.done")
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseReasoningSummaryTextDoneEvent} for more
  39. # details.
  40. #
  41. # Emitted when a reasoning summary text is completed.
  42. #
  43. # @param item_id [String] The ID of the item this summary text is associated with.
  44. #
  45. # @param output_index [Integer] The index of the output item this summary text is associated with.
  46. #
  47. # @param sequence_number [Integer] The sequence number of this event.
  48. #
  49. # @param summary_index [Integer] The index of the summary part within the reasoning summary.
  50. #
  51. # @param text [String] The full text of the completed reasoning summary.
  52. #
  53. # @param type [Symbol, :"response.reasoning_summary_text.done"] The type of the event. Always `response.reasoning_summary_text.done`.
  54. end
  55. end
  56. end
  57. end

openai-ruby/lib/openai/models/responses/response_refusal_delta_event.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseRefusalDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content_index
  7. # The index of the content part that the refusal text is added to.
  8. #
  9. # @return [Integer]
  10. 1 required :content_index, Integer
  11. # @!attribute delta
  12. # The refusal text that is added.
  13. #
  14. # @return [String]
  15. 1 required :delta, String
  16. # @!attribute item_id
  17. # The ID of the output item that the refusal text is added to.
  18. #
  19. # @return [String]
  20. 1 required :item_id, String
  21. # @!attribute output_index
  22. # The index of the output item that the refusal text is added to.
  23. #
  24. # @return [Integer]
  25. 1 required :output_index, Integer
  26. # @!attribute sequence_number
  27. # The sequence number of this event.
  28. #
  29. # @return [Integer]
  30. 1 required :sequence_number, Integer
  31. # @!attribute type
  32. # The type of the event. Always `response.refusal.delta`.
  33. #
  34. # @return [Symbol, :"response.refusal.delta"]
  35. 1 required :type, const: :"response.refusal.delta"
  36. # @!method initialize(content_index:, delta:, item_id:, output_index:, sequence_number:, type: :"response.refusal.delta")
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseRefusalDeltaEvent} for more details.
  39. #
  40. # Emitted when there is a partial refusal text.
  41. #
  42. # @param content_index [Integer] The index of the content part that the refusal text is added to.
  43. #
  44. # @param delta [String] The refusal text that is added.
  45. #
  46. # @param item_id [String] The ID of the output item that the refusal text is added to.
  47. #
  48. # @param output_index [Integer] The index of the output item that the refusal text is added to.
  49. #
  50. # @param sequence_number [Integer] The sequence number of this event.
  51. #
  52. # @param type [Symbol, :"response.refusal.delta"] The type of the event. Always `response.refusal.delta`.
  53. end
  54. end
  55. end
  56. end

openai-ruby/lib/openai/models/responses/response_refusal_done_event.rb

100.0% lines covered

100.0% branches covered

10 relevant lines. 10 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseRefusalDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content_index
  7. # The index of the content part that the refusal text is finalized.
  8. #
  9. # @return [Integer]
  10. 1 required :content_index, Integer
  11. # @!attribute item_id
  12. # The ID of the output item that the refusal text is finalized.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute output_index
  17. # The index of the output item that the refusal text is finalized.
  18. #
  19. # @return [Integer]
  20. 1 required :output_index, Integer
  21. # @!attribute refusal
  22. # The refusal text that is finalized.
  23. #
  24. # @return [String]
  25. 1 required :refusal, String
  26. # @!attribute sequence_number
  27. # The sequence number of this event.
  28. #
  29. # @return [Integer]
  30. 1 required :sequence_number, Integer
  31. # @!attribute type
  32. # The type of the event. Always `response.refusal.done`.
  33. #
  34. # @return [Symbol, :"response.refusal.done"]
  35. 1 required :type, const: :"response.refusal.done"
  36. # @!method initialize(content_index:, item_id:, output_index:, refusal:, sequence_number:, type: :"response.refusal.done")
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::Responses::ResponseRefusalDoneEvent} for more details.
  39. #
  40. # Emitted when refusal text is finalized.
  41. #
  42. # @param content_index [Integer] The index of the content part that the refusal text is finalized.
  43. #
  44. # @param item_id [String] The ID of the output item that the refusal text is finalized.
  45. #
  46. # @param output_index [Integer] The index of the output item that the refusal text is finalized.
  47. #
  48. # @param refusal [String] The refusal text that is finalized.
  49. #
  50. # @param sequence_number [Integer] The sequence number of this event.
  51. #
  52. # @param type [Symbol, :"response.refusal.done"] The type of the event. Always `response.refusal.done`.
  53. end
  54. end
  55. end
  56. end

openai-ruby/lib/openai/models/responses/response_retrieve_params.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # @see OpenAI::Resources::Responses#retrieve
  6. #
  7. # @see OpenAI::Resources::Responses#retrieve_streaming
  8. 1 class ResponseRetrieveParams < OpenAI::Internal::Type::BaseModel
  9. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  10. 1 include OpenAI::Internal::Type::RequestParameters
  11. # @!attribute include
  12. # Additional fields to include in the response. See the `include` parameter for
  13. # Response creation above for more information.
  14. #
  15. # @return [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>, nil]
  16. 1 optional :include, -> { OpenAI::Internal::Type::ArrayOf[enum: OpenAI::Responses::ResponseIncludable] }
  17. # @!attribute starting_after
  18. # The sequence number of the event after which to start streaming.
  19. #
  20. # @return [Integer, nil]
  21. 1 optional :starting_after, Integer
  22. # @!method initialize(include: nil, starting_after: nil, request_options: {})
  23. # Some parameter documentations has been truncated, see
  24. # {OpenAI::Models::Responses::ResponseRetrieveParams} for more details.
  25. #
  26. # @param include [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>] Additional fields to include in the response. See the `include`
  27. #
  28. # @param starting_after [Integer] The sequence number of the event after which to start streaming.
  29. #
  30. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  31. end
  32. end
  33. end
  34. end

openai-ruby/lib/openai/models/responses/response_status.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # The status of the response generation. One of `completed`, `failed`,
  6. # `in_progress`, `cancelled`, `queued`, or `incomplete`.
  7. 1 module ResponseStatus
  8. 1 extend OpenAI::Internal::Type::Enum
  9. 1 COMPLETED = :completed
  10. 1 FAILED = :failed
  11. 1 IN_PROGRESS = :in_progress
  12. 1 CANCELLED = :cancelled
  13. 1 QUEUED = :queued
  14. 1 INCOMPLETE = :incomplete
  15. # @!method self.values
  16. # @return [Array<Symbol>]
  17. end
  18. end
  19. end
  20. end

openai-ruby/lib/openai/models/responses/response_stream_event.rb

66.28% lines covered

100.0% branches covered

86 relevant lines. 57 lines covered and 29 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # Emitted when there is a partial audio response.
  6. 1 module ResponseStreamEvent
  7. 1 extend OpenAI::Internal::Type::Union
  8. 1 discriminator :type
  9. # Emitted when there is a partial audio response.
  10. 1 variant :"response.audio.delta", -> { OpenAI::Responses::ResponseAudioDeltaEvent }
  11. # Emitted when the audio response is complete.
  12. 1 variant :"response.audio.done", -> { OpenAI::Responses::ResponseAudioDoneEvent }
  13. # Emitted when there is a partial transcript of audio.
  14. 1 variant :"response.audio.transcript.delta",
  15. -> {
  16. OpenAI::Responses::ResponseAudioTranscriptDeltaEvent
  17. }
  18. # Emitted when the full audio transcript is completed.
  19. 1 variant :"response.audio.transcript.done", -> { OpenAI::Responses::ResponseAudioTranscriptDoneEvent }
  20. # Emitted when a partial code snippet is streamed by the code interpreter.
  21. 1 variant :"response.code_interpreter_call_code.delta",
  22. -> { OpenAI::Responses::ResponseCodeInterpreterCallCodeDeltaEvent }
  23. # Emitted when the code snippet is finalized by the code interpreter.
  24. 1 variant :"response.code_interpreter_call_code.done",
  25. -> { OpenAI::Responses::ResponseCodeInterpreterCallCodeDoneEvent }
  26. # Emitted when the code interpreter call is completed.
  27. 1 variant :"response.code_interpreter_call.completed",
  28. -> { OpenAI::Responses::ResponseCodeInterpreterCallCompletedEvent }
  29. # Emitted when a code interpreter call is in progress.
  30. 1 variant :"response.code_interpreter_call.in_progress",
  31. -> { OpenAI::Responses::ResponseCodeInterpreterCallInProgressEvent }
  32. # Emitted when the code interpreter is actively interpreting the code snippet.
  33. 1 variant :"response.code_interpreter_call.interpreting",
  34. -> { OpenAI::Responses::ResponseCodeInterpreterCallInterpretingEvent }
  35. # Emitted when the model response is complete.
  36. 1 variant :"response.completed", -> { OpenAI::Responses::ResponseCompletedEvent }
  37. # Emitted when a new content part is added.
  38. 1 variant :"response.content_part.added", -> { OpenAI::Responses::ResponseContentPartAddedEvent }
  39. # Emitted when a content part is done.
  40. 1 variant :"response.content_part.done", -> { OpenAI::Responses::ResponseContentPartDoneEvent }
  41. # An event that is emitted when a response is created.
  42. 1 variant :"response.created", -> { OpenAI::Responses::ResponseCreatedEvent }
  43. # Emitted when an error occurs.
  44. 1 variant :error, -> { OpenAI::Responses::ResponseErrorEvent }
  45. # Emitted when a file search call is completed (results found).
  46. 1 variant :"response.file_search_call.completed",
  47. -> { OpenAI::Responses::ResponseFileSearchCallCompletedEvent }
  48. # Emitted when a file search call is initiated.
  49. 1 variant :"response.file_search_call.in_progress",
  50. -> { OpenAI::Responses::ResponseFileSearchCallInProgressEvent }
  51. # Emitted when a file search is currently searching.
  52. 1 variant :"response.file_search_call.searching",
  53. -> { OpenAI::Responses::ResponseFileSearchCallSearchingEvent }
  54. # Emitted when there is a partial function-call arguments delta.
  55. 1 variant :"response.function_call_arguments.delta",
  56. -> { OpenAI::Responses::ResponseFunctionCallArgumentsDeltaEvent }
  57. # Emitted when function-call arguments are finalized.
  58. 1 variant :"response.function_call_arguments.done",
  59. -> { OpenAI::Responses::ResponseFunctionCallArgumentsDoneEvent }
  60. # Emitted when the response is in progress.
  61. 1 variant :"response.in_progress", -> { OpenAI::Responses::ResponseInProgressEvent }
  62. # An event that is emitted when a response fails.
  63. 1 variant :"response.failed", -> { OpenAI::Responses::ResponseFailedEvent }
  64. # An event that is emitted when a response finishes as incomplete.
  65. 1 variant :"response.incomplete", -> { OpenAI::Responses::ResponseIncompleteEvent }
  66. # Emitted when a new output item is added.
  67. 1 variant :"response.output_item.added", -> { OpenAI::Responses::ResponseOutputItemAddedEvent }
  68. # Emitted when an output item is marked done.
  69. 1 variant :"response.output_item.done", -> { OpenAI::Responses::ResponseOutputItemDoneEvent }
  70. # Emitted when a new reasoning summary part is added.
  71. 1 variant :"response.reasoning_summary_part.added",
  72. -> { OpenAI::Responses::ResponseReasoningSummaryPartAddedEvent }
  73. # Emitted when a reasoning summary part is completed.
  74. 1 variant :"response.reasoning_summary_part.done",
  75. -> { OpenAI::Responses::ResponseReasoningSummaryPartDoneEvent }
  76. # Emitted when a delta is added to a reasoning summary text.
  77. 1 variant :"response.reasoning_summary_text.delta",
  78. -> { OpenAI::Responses::ResponseReasoningSummaryTextDeltaEvent }
  79. # Emitted when a reasoning summary text is completed.
  80. 1 variant :"response.reasoning_summary_text.done",
  81. -> { OpenAI::Responses::ResponseReasoningSummaryTextDoneEvent }
  82. # Emitted when there is a partial refusal text.
  83. 1 variant :"response.refusal.delta", -> { OpenAI::Responses::ResponseRefusalDeltaEvent }
  84. # Emitted when refusal text is finalized.
  85. 1 variant :"response.refusal.done", -> { OpenAI::Responses::ResponseRefusalDoneEvent }
  86. # Emitted when there is an additional text delta.
  87. 1 variant :"response.output_text.delta", -> { OpenAI::Responses::ResponseTextDeltaEvent }
  88. # Emitted when text content is finalized.
  89. 1 variant :"response.output_text.done", -> { OpenAI::Responses::ResponseTextDoneEvent }
  90. # Emitted when a web search call is completed.
  91. 1 variant :"response.web_search_call.completed",
  92. -> { OpenAI::Responses::ResponseWebSearchCallCompletedEvent }
  93. # Emitted when a web search call is initiated.
  94. 1 variant :"response.web_search_call.in_progress",
  95. -> { OpenAI::Responses::ResponseWebSearchCallInProgressEvent }
  96. # Emitted when a web search call is executing.
  97. 1 variant :"response.web_search_call.searching",
  98. -> { OpenAI::Responses::ResponseWebSearchCallSearchingEvent }
  99. # Emitted when an image generation tool call has completed and the final image is available.
  100. 1 variant :"response.image_generation_call.completed",
  101. -> { OpenAI::Responses::ResponseImageGenCallCompletedEvent }
  102. # Emitted when an image generation tool call is actively generating an image (intermediate state).
  103. 1 variant :"response.image_generation_call.generating",
  104. -> { OpenAI::Responses::ResponseImageGenCallGeneratingEvent }
  105. # Emitted when an image generation tool call is in progress.
  106. 1 variant :"response.image_generation_call.in_progress",
  107. -> { OpenAI::Responses::ResponseImageGenCallInProgressEvent }
  108. # Emitted when a partial image is available during image generation streaming.
  109. 1 variant :"response.image_generation_call.partial_image",
  110. -> { OpenAI::Responses::ResponseImageGenCallPartialImageEvent }
  111. # Emitted when there is a delta (partial update) to the arguments of an MCP tool call.
  112. 1 variant :"response.mcp_call_arguments.delta",
  113. -> {
  114. OpenAI::Responses::ResponseMcpCallArgumentsDeltaEvent
  115. }
  116. # Emitted when the arguments for an MCP tool call are finalized.
  117. 1 variant :"response.mcp_call_arguments.done",
  118. -> {
  119. OpenAI::Responses::ResponseMcpCallArgumentsDoneEvent
  120. }
  121. # Emitted when an MCP tool call has completed successfully.
  122. 1 variant :"response.mcp_call.completed", -> { OpenAI::Responses::ResponseMcpCallCompletedEvent }
  123. # Emitted when an MCP tool call has failed.
  124. 1 variant :"response.mcp_call.failed", -> { OpenAI::Responses::ResponseMcpCallFailedEvent }
  125. # Emitted when an MCP tool call is in progress.
  126. 1 variant :"response.mcp_call.in_progress", -> { OpenAI::Responses::ResponseMcpCallInProgressEvent }
  127. # Emitted when the list of available MCP tools has been successfully retrieved.
  128. 1 variant :"response.mcp_list_tools.completed",
  129. -> {
  130. OpenAI::Responses::ResponseMcpListToolsCompletedEvent
  131. }
  132. # Emitted when the attempt to list available MCP tools has failed.
  133. 1 variant :"response.mcp_list_tools.failed", -> { OpenAI::Responses::ResponseMcpListToolsFailedEvent }
  134. # Emitted when the system is in the process of retrieving the list of available MCP tools.
  135. 1 variant :"response.mcp_list_tools.in_progress",
  136. -> { OpenAI::Responses::ResponseMcpListToolsInProgressEvent }
  137. # Emitted when an annotation is added to output text content.
  138. 1 variant :"response.output_text.annotation.added",
  139. -> { OpenAI::Responses::ResponseOutputTextAnnotationAddedEvent }
  140. # Emitted when a response is queued and waiting to be processed.
  141. 1 variant :"response.queued", -> { OpenAI::Responses::ResponseQueuedEvent }
  142. # Emitted when there is a delta (partial update) to the reasoning summary content.
  143. 1 variant :"response.reasoning_summary.delta",
  144. -> {
  145. OpenAI::Responses::ResponseReasoningSummaryDeltaEvent
  146. }
  147. # Emitted when the reasoning summary content is finalized for an item.
  148. 1 variant :"response.reasoning_summary.done",
  149. -> {
  150. OpenAI::Responses::ResponseReasoningSummaryDoneEvent
  151. }
  152. # @!method self.variants
  153. # @return [Array(OpenAI::Models::Responses::ResponseAudioDeltaEvent, OpenAI::Models::Responses::ResponseAudioDoneEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent, OpenAI::Models::Responses::ResponseCompletedEvent, OpenAI::Models::Responses::ResponseContentPartAddedEvent, OpenAI::Models::Responses::ResponseContentPartDoneEvent, OpenAI::Models::Responses::ResponseCreatedEvent, OpenAI::Models::Responses::ResponseErrorEvent, OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseInProgressEvent, OpenAI::Models::Responses::ResponseFailedEvent, OpenAI::Models::Responses::ResponseIncompleteEvent, OpenAI::Models::Responses::ResponseOutputItemAddedEvent, OpenAI::Models::Responses::ResponseOutputItemDoneEvent, OpenAI::Models::Responses::ResponseReasoningSummaryPartAddedEvent, OpenAI::Models::Responses::ResponseReasoningSummaryPartDoneEvent, OpenAI::Models::Responses::ResponseReasoningSummaryTextDeltaEvent, OpenAI::Models::Responses::ResponseReasoningSummaryTextDoneEvent, OpenAI::Models::Responses::ResponseRefusalDeltaEvent, OpenAI::Models::Responses::ResponseRefusalDoneEvent, OpenAI::Models::Responses::ResponseTextDeltaEvent, OpenAI::Models::Responses::ResponseTextDoneEvent, OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseImageGenCallCompletedEvent, OpenAI::Models::Responses::ResponseImageGenCallGeneratingEvent, OpenAI::Models::Responses::ResponseImageGenCallInProgressEvent, OpenAI::Models::Responses::ResponseImageGenCallPartialImageEvent, OpenAI::Models::Responses::ResponseMcpCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseMcpCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseMcpCallCompletedEvent, OpenAI::Models::Responses::ResponseMcpCallFailedEvent, OpenAI::Models::Responses::ResponseMcpCallInProgressEvent, OpenAI::Models::Responses::ResponseMcpListToolsCompletedEvent, OpenAI::Models::Responses::ResponseMcpListToolsFailedEvent, OpenAI::Models::Responses::ResponseMcpListToolsInProgressEvent, OpenAI::Models::Responses::ResponseOutputTextAnnotationAddedEvent, OpenAI::Models::Responses::ResponseQueuedEvent, OpenAI::Models::Responses::ResponseReasoningSummaryDeltaEvent, OpenAI::Models::Responses::ResponseReasoningSummaryDoneEvent)]
  154. end
  155. end
  156. end
  157. end

openai-ruby/lib/openai/models/responses/response_text_config.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseTextConfig < OpenAI::Internal::Type::BaseModel
  6. # @!attribute format_
  7. # An object specifying the format that the model must output.
  8. #
  9. # Configuring `{ "type": "json_schema" }` enables Structured Outputs, which
  10. # ensures the model will match your supplied JSON schema. Learn more in the
  11. # [Structured Outputs guide](https://platform.openai.com/docs/guides/structured-outputs).
  12. #
  13. # The default format is `{ "type": "text" }` with no additional options.
  14. #
  15. # **Not recommended for gpt-4o and newer models:**
  16. #
  17. # Setting to `{ "type": "json_object" }` enables the older JSON mode, which
  18. # ensures the message the model generates is valid JSON. Using `json_schema` is
  19. # preferred for models that support it.
  20. #
  21. # @return [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject, nil]
  22. 1 optional :format_, union: -> { OpenAI::Responses::ResponseFormatTextConfig }, api_name: :format
  23. # @!method initialize(format_: nil)
  24. # Some parameter documentations has been truncated, see
  25. # {OpenAI::Models::Responses::ResponseTextConfig} for more details.
  26. #
  27. # Configuration options for a text response from the model. Can be plain text or
  28. # structured JSON data. Learn more:
  29. #
  30. # - [Text inputs and outputs](https://platform.openai.com/docs/guides/text)
  31. # - [Structured Outputs](https://platform.openai.com/docs/guides/structured-outputs)
  32. #
  33. # @param format_ [OpenAI::Models::ResponseFormatText, OpenAI::Models::Responses::ResponseFormatTextJSONSchemaConfig, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  34. end
  35. end
  36. end
  37. end

openai-ruby/lib/openai/models/responses/response_text_delta_event.rb

90.0% lines covered

100.0% branches covered

20 relevant lines. 18 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseTextDeltaEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content_index
  7. # The index of the content part that the text delta was added to.
  8. #
  9. # @return [Integer]
  10. 1 required :content_index, Integer
  11. # @!attribute delta
  12. # The text delta that was added.
  13. #
  14. # @return [String]
  15. 1 required :delta, String
  16. # @!attribute item_id
  17. # The ID of the output item that the text delta was added to.
  18. #
  19. # @return [String]
  20. 1 required :item_id, String
  21. # @!attribute logprobs
  22. # The log probabilities of the tokens in the delta.
  23. #
  24. # @return [Array<OpenAI::Models::Responses::ResponseTextDeltaEvent::Logprob>]
  25. 1 required :logprobs,
  26. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseTextDeltaEvent::Logprob] }
  27. # @!attribute output_index
  28. # The index of the output item that the text delta was added to.
  29. #
  30. # @return [Integer]
  31. 1 required :output_index, Integer
  32. # @!attribute sequence_number
  33. # The sequence number for this event.
  34. #
  35. # @return [Integer]
  36. 1 required :sequence_number, Integer
  37. # @!attribute type
  38. # The type of the event. Always `response.output_text.delta`.
  39. #
  40. # @return [Symbol, :"response.output_text.delta"]
  41. 1 required :type, const: :"response.output_text.delta"
  42. # @!method initialize(content_index:, delta:, item_id:, logprobs:, output_index:, sequence_number:, type: :"response.output_text.delta")
  43. # Some parameter documentations has been truncated, see
  44. # {OpenAI::Models::Responses::ResponseTextDeltaEvent} for more details.
  45. #
  46. # Emitted when there is an additional text delta.
  47. #
  48. # @param content_index [Integer] The index of the content part that the text delta was added to.
  49. #
  50. # @param delta [String] The text delta that was added.
  51. #
  52. # @param item_id [String] The ID of the output item that the text delta was added to.
  53. #
  54. # @param logprobs [Array<OpenAI::Models::Responses::ResponseTextDeltaEvent::Logprob>] The log probabilities of the tokens in the delta.
  55. #
  56. # @param output_index [Integer] The index of the output item that the text delta was added to.
  57. #
  58. # @param sequence_number [Integer] The sequence number for this event.
  59. #
  60. # @param type [Symbol, :"response.output_text.delta"] The type of the event. Always `response.output_text.delta`.
  61. 1 class Logprob < OpenAI::Internal::Type::BaseModel
  62. # @!attribute token
  63. # A possible text token.
  64. #
  65. # @return [String]
  66. 1 required :token, String
  67. # @!attribute logprob
  68. # The log probability of this token.
  69. #
  70. # @return [Float]
  71. 1 required :logprob, Float
  72. # @!attribute top_logprobs
  73. # The log probability of the top 20 most likely tokens.
  74. #
  75. # @return [Array<OpenAI::Models::Responses::ResponseTextDeltaEvent::Logprob::TopLogprob>, nil]
  76. 1 optional :top_logprobs,
  77. -> {
  78. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseTextDeltaEvent::Logprob::TopLogprob]
  79. }
  80. # @!method initialize(token:, logprob:, top_logprobs: nil)
  81. # Some parameter documentations has been truncated, see
  82. # {OpenAI::Models::Responses::ResponseTextDeltaEvent::Logprob} for more details.
  83. #
  84. # A logprob is the logarithmic probability that the model assigns to producing a
  85. # particular token at a given position in the sequence. Less-negative (higher)
  86. # logprob values indicate greater model confidence in that token choice.
  87. #
  88. # @param token [String] A possible text token.
  89. #
  90. # @param logprob [Float] The log probability of this token.
  91. #
  92. # @param top_logprobs [Array<OpenAI::Models::Responses::ResponseTextDeltaEvent::Logprob::TopLogprob>] The log probability of the top 20 most likely tokens.
  93. 1 class TopLogprob < OpenAI::Internal::Type::BaseModel
  94. # @!attribute token
  95. # A possible text token.
  96. #
  97. # @return [String, nil]
  98. 1 optional :token, String
  99. # @!attribute logprob
  100. # The log probability of this token.
  101. #
  102. # @return [Float, nil]
  103. 1 optional :logprob, Float
  104. # @!method initialize(token: nil, logprob: nil)
  105. # @param token [String] A possible text token.
  106. #
  107. # @param logprob [Float] The log probability of this token.
  108. end
  109. end
  110. end
  111. end
  112. end
  113. end

openai-ruby/lib/openai/models/responses/response_text_done_event.rb

90.0% lines covered

100.0% branches covered

20 relevant lines. 18 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseTextDoneEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute content_index
  7. # The index of the content part that the text content is finalized.
  8. #
  9. # @return [Integer]
  10. 1 required :content_index, Integer
  11. # @!attribute item_id
  12. # The ID of the output item that the text content is finalized.
  13. #
  14. # @return [String]
  15. 1 required :item_id, String
  16. # @!attribute logprobs
  17. # The log probabilities of the tokens in the delta.
  18. #
  19. # @return [Array<OpenAI::Models::Responses::ResponseTextDoneEvent::Logprob>]
  20. 1 required :logprobs,
  21. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseTextDoneEvent::Logprob] }
  22. # @!attribute output_index
  23. # The index of the output item that the text content is finalized.
  24. #
  25. # @return [Integer]
  26. 1 required :output_index, Integer
  27. # @!attribute sequence_number
  28. # The sequence number for this event.
  29. #
  30. # @return [Integer]
  31. 1 required :sequence_number, Integer
  32. # @!attribute text
  33. # The text content that is finalized.
  34. #
  35. # @return [String]
  36. 1 required :text, String
  37. # @!attribute type
  38. # The type of the event. Always `response.output_text.done`.
  39. #
  40. # @return [Symbol, :"response.output_text.done"]
  41. 1 required :type, const: :"response.output_text.done"
  42. # @!method initialize(content_index:, item_id:, logprobs:, output_index:, sequence_number:, text:, type: :"response.output_text.done")
  43. # Some parameter documentations has been truncated, see
  44. # {OpenAI::Models::Responses::ResponseTextDoneEvent} for more details.
  45. #
  46. # Emitted when text content is finalized.
  47. #
  48. # @param content_index [Integer] The index of the content part that the text content is finalized.
  49. #
  50. # @param item_id [String] The ID of the output item that the text content is finalized.
  51. #
  52. # @param logprobs [Array<OpenAI::Models::Responses::ResponseTextDoneEvent::Logprob>] The log probabilities of the tokens in the delta.
  53. #
  54. # @param output_index [Integer] The index of the output item that the text content is finalized.
  55. #
  56. # @param sequence_number [Integer] The sequence number for this event.
  57. #
  58. # @param text [String] The text content that is finalized.
  59. #
  60. # @param type [Symbol, :"response.output_text.done"] The type of the event. Always `response.output_text.done`.
  61. 1 class Logprob < OpenAI::Internal::Type::BaseModel
  62. # @!attribute token
  63. # A possible text token.
  64. #
  65. # @return [String]
  66. 1 required :token, String
  67. # @!attribute logprob
  68. # The log probability of this token.
  69. #
  70. # @return [Float]
  71. 1 required :logprob, Float
  72. # @!attribute top_logprobs
  73. # The log probability of the top 20 most likely tokens.
  74. #
  75. # @return [Array<OpenAI::Models::Responses::ResponseTextDoneEvent::Logprob::TopLogprob>, nil]
  76. 1 optional :top_logprobs,
  77. -> {
  78. OpenAI::Internal::Type::ArrayOf[OpenAI::Responses::ResponseTextDoneEvent::Logprob::TopLogprob]
  79. }
  80. # @!method initialize(token:, logprob:, top_logprobs: nil)
  81. # Some parameter documentations has been truncated, see
  82. # {OpenAI::Models::Responses::ResponseTextDoneEvent::Logprob} for more details.
  83. #
  84. # A logprob is the logarithmic probability that the model assigns to producing a
  85. # particular token at a given position in the sequence. Less-negative (higher)
  86. # logprob values indicate greater model confidence in that token choice.
  87. #
  88. # @param token [String] A possible text token.
  89. #
  90. # @param logprob [Float] The log probability of this token.
  91. #
  92. # @param top_logprobs [Array<OpenAI::Models::Responses::ResponseTextDoneEvent::Logprob::TopLogprob>] The log probability of the top 20 most likely tokens.
  93. 1 class TopLogprob < OpenAI::Internal::Type::BaseModel
  94. # @!attribute token
  95. # A possible text token.
  96. #
  97. # @return [String, nil]
  98. 1 optional :token, String
  99. # @!attribute logprob
  100. # The log probability of this token.
  101. #
  102. # @return [Float, nil]
  103. 1 optional :logprob, Float
  104. # @!method initialize(token: nil, logprob: nil)
  105. # @param token [String] A possible text token.
  106. #
  107. # @param logprob [Float] The log probability of this token.
  108. end
  109. end
  110. end
  111. end
  112. end
  113. end

openai-ruby/lib/openai/models/responses/response_usage.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseUsage < OpenAI::Internal::Type::BaseModel
  6. # @!attribute input_tokens
  7. # The number of input tokens.
  8. #
  9. # @return [Integer]
  10. 1 required :input_tokens, Integer
  11. # @!attribute input_tokens_details
  12. # A detailed breakdown of the input tokens.
  13. #
  14. # @return [OpenAI::Models::Responses::ResponseUsage::InputTokensDetails]
  15. 1 required :input_tokens_details, -> { OpenAI::Responses::ResponseUsage::InputTokensDetails }
  16. # @!attribute output_tokens
  17. # The number of output tokens.
  18. #
  19. # @return [Integer]
  20. 1 required :output_tokens, Integer
  21. # @!attribute output_tokens_details
  22. # A detailed breakdown of the output tokens.
  23. #
  24. # @return [OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails]
  25. 1 required :output_tokens_details, -> { OpenAI::Responses::ResponseUsage::OutputTokensDetails }
  26. # @!attribute total_tokens
  27. # The total number of tokens used.
  28. #
  29. # @return [Integer]
  30. 1 required :total_tokens, Integer
  31. # @!method initialize(input_tokens:, input_tokens_details:, output_tokens:, output_tokens_details:, total_tokens:)
  32. # Represents token usage details including input tokens, output tokens, a
  33. # breakdown of output tokens, and the total tokens used.
  34. #
  35. # @param input_tokens [Integer] The number of input tokens.
  36. #
  37. # @param input_tokens_details [OpenAI::Models::Responses::ResponseUsage::InputTokensDetails] A detailed breakdown of the input tokens.
  38. #
  39. # @param output_tokens [Integer] The number of output tokens.
  40. #
  41. # @param output_tokens_details [OpenAI::Models::Responses::ResponseUsage::OutputTokensDetails] A detailed breakdown of the output tokens.
  42. #
  43. # @param total_tokens [Integer] The total number of tokens used.
  44. # @see OpenAI::Models::Responses::ResponseUsage#input_tokens_details
  45. 1 class InputTokensDetails < OpenAI::Internal::Type::BaseModel
  46. # @!attribute cached_tokens
  47. # The number of tokens that were retrieved from the cache.
  48. # [More on prompt caching](https://platform.openai.com/docs/guides/prompt-caching).
  49. #
  50. # @return [Integer]
  51. 1 required :cached_tokens, Integer
  52. # @!method initialize(cached_tokens:)
  53. # Some parameter documentations has been truncated, see
  54. # {OpenAI::Models::Responses::ResponseUsage::InputTokensDetails} for more details.
  55. #
  56. # A detailed breakdown of the input tokens.
  57. #
  58. # @param cached_tokens [Integer] The number of tokens that were retrieved from the cache.
  59. end
  60. # @see OpenAI::Models::Responses::ResponseUsage#output_tokens_details
  61. 1 class OutputTokensDetails < OpenAI::Internal::Type::BaseModel
  62. # @!attribute reasoning_tokens
  63. # The number of reasoning tokens.
  64. #
  65. # @return [Integer]
  66. 1 required :reasoning_tokens, Integer
  67. # @!method initialize(reasoning_tokens:)
  68. # A detailed breakdown of the output tokens.
  69. #
  70. # @param reasoning_tokens [Integer] The number of reasoning tokens.
  71. end
  72. end
  73. end
  74. end
  75. end

openai-ruby/lib/openai/models/responses/response_web_search_call_completed_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseWebSearchCallCompletedEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # Unique ID for the output item associated with the web search call.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that the web search call is associated with.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of the web search call being processed.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always `response.web_search_call.completed`.
  23. #
  24. # @return [Symbol, :"response.web_search_call.completed"]
  25. 1 required :type, const: :"response.web_search_call.completed"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.web_search_call.completed")
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent} for more
  29. # details.
  30. #
  31. # Emitted when a web search call is completed.
  32. #
  33. # @param item_id [String] Unique ID for the output item associated with the web search call.
  34. #
  35. # @param output_index [Integer] The index of the output item that the web search call is associated with.
  36. #
  37. # @param sequence_number [Integer] The sequence number of the web search call being processed.
  38. #
  39. # @param type [Symbol, :"response.web_search_call.completed"] The type of the event. Always `response.web_search_call.completed`.
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/responses/response_web_search_call_in_progress_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseWebSearchCallInProgressEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # Unique ID for the output item associated with the web search call.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that the web search call is associated with.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of the web search call being processed.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always `response.web_search_call.in_progress`.
  23. #
  24. # @return [Symbol, :"response.web_search_call.in_progress"]
  25. 1 required :type, const: :"response.web_search_call.in_progress"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.web_search_call.in_progress")
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent} for more
  29. # details.
  30. #
  31. # Emitted when a web search call is initiated.
  32. #
  33. # @param item_id [String] Unique ID for the output item associated with the web search call.
  34. #
  35. # @param output_index [Integer] The index of the output item that the web search call is associated with.
  36. #
  37. # @param sequence_number [Integer] The sequence number of the web search call being processed.
  38. #
  39. # @param type [Symbol, :"response.web_search_call.in_progress"] The type of the event. Always `response.web_search_call.in_progress`.
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/responses/response_web_search_call_searching_event.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ResponseWebSearchCallSearchingEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute item_id
  7. # Unique ID for the output item associated with the web search call.
  8. #
  9. # @return [String]
  10. 1 required :item_id, String
  11. # @!attribute output_index
  12. # The index of the output item that the web search call is associated with.
  13. #
  14. # @return [Integer]
  15. 1 required :output_index, Integer
  16. # @!attribute sequence_number
  17. # The sequence number of the web search call being processed.
  18. #
  19. # @return [Integer]
  20. 1 required :sequence_number, Integer
  21. # @!attribute type
  22. # The type of the event. Always `response.web_search_call.searching`.
  23. #
  24. # @return [Symbol, :"response.web_search_call.searching"]
  25. 1 required :type, const: :"response.web_search_call.searching"
  26. # @!method initialize(item_id:, output_index:, sequence_number:, type: :"response.web_search_call.searching")
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent} for more
  29. # details.
  30. #
  31. # Emitted when a web search call is executing.
  32. #
  33. # @param item_id [String] Unique ID for the output item associated with the web search call.
  34. #
  35. # @param output_index [Integer] The index of the output item that the web search call is associated with.
  36. #
  37. # @param sequence_number [Integer] The sequence number of the web search call being processed.
  38. #
  39. # @param type [Symbol, :"response.web_search_call.searching"] The type of the event. Always `response.web_search_call.searching`.
  40. end
  41. end
  42. end
  43. end

openai-ruby/lib/openai/models/responses/tool.rb

97.22% lines covered

100.0% branches covered

108 relevant lines. 105 lines covered and 3 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # A tool that can be used to generate a response.
  6. 1 module Tool
  7. 1 extend OpenAI::Internal::Type::Union
  8. 1 discriminator :type
  9. # Defines a function in your own code the model can choose to call. Learn more about [function calling](https://platform.openai.com/docs/guides/function-calling).
  10. 1 variant :function, -> { OpenAI::Responses::FunctionTool }
  11. 1 variant -> { OpenAI::StructuredOutput::JsonSchemaConverter }
  12. # A tool that searches for relevant content from uploaded files. Learn more about the [file search tool](https://platform.openai.com/docs/guides/tools-file-search).
  13. 1 variant :file_search, -> { OpenAI::Responses::FileSearchTool }
  14. # A tool that controls a virtual computer. Learn more about the [computer tool](https://platform.openai.com/docs/guides/tools-computer-use).
  15. 1 variant :computer_use_preview, -> { OpenAI::Responses::ComputerTool }
  16. # Give the model access to additional tools via remote Model Context Protocol
  17. # (MCP) servers. [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
  18. 1 variant :mcp, -> { OpenAI::Responses::Tool::Mcp }
  19. # A tool that runs Python code to help generate a response to a prompt.
  20. 1 variant :code_interpreter, -> { OpenAI::Responses::Tool::CodeInterpreter }
  21. # A tool that generates images using a model like `gpt-image-1`.
  22. 1 variant :image_generation, -> { OpenAI::Responses::Tool::ImageGeneration }
  23. # A tool that allows the model to execute shell commands in a local environment.
  24. 1 variant :local_shell, -> { OpenAI::Responses::Tool::LocalShell }
  25. # This tool searches the web for relevant results to use in a response. Learn more about the [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
  26. 1 variant -> { OpenAI::Responses::WebSearchTool }
  27. 1 class Mcp < OpenAI::Internal::Type::BaseModel
  28. # @!attribute server_label
  29. # A label for this MCP server, used to identify it in tool calls.
  30. #
  31. # @return [String]
  32. 1 required :server_label, String
  33. # @!attribute server_url
  34. # The URL for the MCP server.
  35. #
  36. # @return [String]
  37. 1 required :server_url, String
  38. # @!attribute type
  39. # The type of the MCP tool. Always `mcp`.
  40. #
  41. # @return [Symbol, :mcp]
  42. 1 required :type, const: :mcp
  43. # @!attribute allowed_tools
  44. # List of allowed tool names or a filter object.
  45. #
  46. # @return [Array<String>, OpenAI::Models::Responses::Tool::Mcp::AllowedTools::McpAllowedToolsFilter, nil]
  47. 1 optional :allowed_tools, union: -> { OpenAI::Responses::Tool::Mcp::AllowedTools }, nil?: true
  48. # @!attribute headers
  49. # Optional HTTP headers to send to the MCP server. Use for authentication or other
  50. # purposes.
  51. #
  52. # @return [Hash{Symbol=>String}, nil]
  53. 1 optional :headers, OpenAI::Internal::Type::HashOf[String], nil?: true
  54. # @!attribute require_approval
  55. # Specify which of the MCP server's tools require approval.
  56. #
  57. # @return [OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter, Symbol, OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalSetting, nil]
  58. 1 optional :require_approval, union: -> { OpenAI::Responses::Tool::Mcp::RequireApproval }, nil?: true
  59. # @!attribute server_description
  60. # Optional description of the MCP server, used to provide more context.
  61. #
  62. # @return [String, nil]
  63. 1 optional :server_description, String
  64. # @!method initialize(server_label:, server_url:, allowed_tools: nil, headers: nil, require_approval: nil, server_description: nil, type: :mcp)
  65. # Some parameter documentations has been truncated, see
  66. # {OpenAI::Models::Responses::Tool::Mcp} for more details.
  67. #
  68. # Give the model access to additional tools via remote Model Context Protocol
  69. # (MCP) servers.
  70. # [Learn more about MCP](https://platform.openai.com/docs/guides/tools-remote-mcp).
  71. #
  72. # @param server_label [String] A label for this MCP server, used to identify it in tool calls.
  73. #
  74. # @param server_url [String] The URL for the MCP server.
  75. #
  76. # @param allowed_tools [Array<String>, OpenAI::Models::Responses::Tool::Mcp::AllowedTools::McpAllowedToolsFilter, nil] List of allowed tool names or a filter object.
  77. #
  78. # @param headers [Hash{Symbol=>String}, nil] Optional HTTP headers to send to the MCP server. Use for authentication
  79. #
  80. # @param require_approval [OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter, Symbol, OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalSetting, nil] Specify which of the MCP server's tools require approval.
  81. #
  82. # @param server_description [String] Optional description of the MCP server, used to provide more context.
  83. #
  84. # @param type [Symbol, :mcp] The type of the MCP tool. Always `mcp`.
  85. # List of allowed tool names or a filter object.
  86. #
  87. # @see OpenAI::Models::Responses::Tool::Mcp#allowed_tools
  88. 1 module AllowedTools
  89. 1 extend OpenAI::Internal::Type::Union
  90. # A string array of allowed tool names
  91. 1 variant -> { OpenAI::Models::Responses::Tool::Mcp::AllowedTools::StringArray }
  92. # A filter object to specify which tools are allowed.
  93. 1 variant -> { OpenAI::Responses::Tool::Mcp::AllowedTools::McpAllowedToolsFilter }
  94. 1 class McpAllowedToolsFilter < OpenAI::Internal::Type::BaseModel
  95. # @!attribute tool_names
  96. # List of allowed tool names.
  97. #
  98. # @return [Array<String>, nil]
  99. 1 optional :tool_names, OpenAI::Internal::Type::ArrayOf[String]
  100. # @!method initialize(tool_names: nil)
  101. # A filter object to specify which tools are allowed.
  102. #
  103. # @param tool_names [Array<String>] List of allowed tool names.
  104. end
  105. # @!method self.variants
  106. # @return [Array(Array<String>, OpenAI::Models::Responses::Tool::Mcp::AllowedTools::McpAllowedToolsFilter)]
  107. # @type [OpenAI::Internal::Type::Converter]
  108. 1 StringArray = OpenAI::Internal::Type::ArrayOf[String]
  109. end
  110. # Specify which of the MCP server's tools require approval.
  111. #
  112. # @see OpenAI::Models::Responses::Tool::Mcp#require_approval
  113. 1 module RequireApproval
  114. 1 extend OpenAI::Internal::Type::Union
  115. 1 variant -> { OpenAI::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter }
  116. # Specify a single approval policy for all tools. One of `always` or
  117. # `never`. When set to `always`, all tools will require approval. When
  118. # set to `never`, all tools will not require approval.
  119. 1 variant enum: -> { OpenAI::Responses::Tool::Mcp::RequireApproval::McpToolApprovalSetting }
  120. 1 class McpToolApprovalFilter < OpenAI::Internal::Type::BaseModel
  121. # @!attribute always
  122. # A list of tools that always require approval.
  123. #
  124. # @return [OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter::Always, nil]
  125. 1 optional :always,
  126. -> {
  127. OpenAI::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter::Always
  128. }
  129. # @!attribute never
  130. # A list of tools that never require approval.
  131. #
  132. # @return [OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter::Never, nil]
  133. 1 optional :never,
  134. -> {
  135. OpenAI::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter::Never
  136. }
  137. # @!method initialize(always: nil, never: nil)
  138. # Some parameter documentations has been truncated, see
  139. # {OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter}
  140. # for more details.
  141. #
  142. # @param always [OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter::Always] A list of tools that always require approval.
  143. #
  144. # @param never [OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter::Never] A list of tools that never require approval.
  145. # @see OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter#always
  146. 1 class Always < OpenAI::Internal::Type::BaseModel
  147. # @!attribute tool_names
  148. # List of tools that require approval.
  149. #
  150. # @return [Array<String>, nil]
  151. 1 optional :tool_names, OpenAI::Internal::Type::ArrayOf[String]
  152. # @!method initialize(tool_names: nil)
  153. # A list of tools that always require approval.
  154. #
  155. # @param tool_names [Array<String>] List of tools that require approval.
  156. end
  157. # @see OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter#never
  158. 1 class Never < OpenAI::Internal::Type::BaseModel
  159. # @!attribute tool_names
  160. # List of tools that do not require approval.
  161. #
  162. # @return [Array<String>, nil]
  163. 1 optional :tool_names, OpenAI::Internal::Type::ArrayOf[String]
  164. # @!method initialize(tool_names: nil)
  165. # A list of tools that never require approval.
  166. #
  167. # @param tool_names [Array<String>] List of tools that do not require approval.
  168. end
  169. end
  170. # Specify a single approval policy for all tools. One of `always` or `never`. When
  171. # set to `always`, all tools will require approval. When set to `never`, all tools
  172. # will not require approval.
  173. 1 module McpToolApprovalSetting
  174. 1 extend OpenAI::Internal::Type::Enum
  175. 1 ALWAYS = :always
  176. 1 NEVER = :never
  177. # @!method self.values
  178. # @return [Array<Symbol>]
  179. end
  180. # @!method self.variants
  181. # @return [Array(OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalFilter, Symbol, OpenAI::Models::Responses::Tool::Mcp::RequireApproval::McpToolApprovalSetting)]
  182. end
  183. end
  184. 1 class CodeInterpreter < OpenAI::Internal::Type::BaseModel
  185. # @!attribute container
  186. # The code interpreter container. Can be a container ID or an object that
  187. # specifies uploaded file IDs to make available to your code.
  188. #
  189. # @return [String, OpenAI::Models::Responses::Tool::CodeInterpreter::Container::CodeInterpreterToolAuto]
  190. 1 required :container, union: -> { OpenAI::Responses::Tool::CodeInterpreter::Container }
  191. # @!attribute type
  192. # The type of the code interpreter tool. Always `code_interpreter`.
  193. #
  194. # @return [Symbol, :code_interpreter]
  195. 1 required :type, const: :code_interpreter
  196. # @!method initialize(container:, type: :code_interpreter)
  197. # Some parameter documentations has been truncated, see
  198. # {OpenAI::Models::Responses::Tool::CodeInterpreter} for more details.
  199. #
  200. # A tool that runs Python code to help generate a response to a prompt.
  201. #
  202. # @param container [String, OpenAI::Models::Responses::Tool::CodeInterpreter::Container::CodeInterpreterToolAuto] The code interpreter container. Can be a container ID or an object that
  203. #
  204. # @param type [Symbol, :code_interpreter] The type of the code interpreter tool. Always `code_interpreter`.
  205. # The code interpreter container. Can be a container ID or an object that
  206. # specifies uploaded file IDs to make available to your code.
  207. #
  208. # @see OpenAI::Models::Responses::Tool::CodeInterpreter#container
  209. 1 module Container
  210. 1 extend OpenAI::Internal::Type::Union
  211. # The container ID.
  212. 1 variant String
  213. # Configuration for a code interpreter container. Optionally specify the IDs
  214. # of the files to run the code on.
  215. 1 variant -> { OpenAI::Responses::Tool::CodeInterpreter::Container::CodeInterpreterToolAuto }
  216. 1 class CodeInterpreterToolAuto < OpenAI::Internal::Type::BaseModel
  217. # @!attribute type
  218. # Always `auto`.
  219. #
  220. # @return [Symbol, :auto]
  221. 1 required :type, const: :auto
  222. # @!attribute file_ids
  223. # An optional list of uploaded files to make available to your code.
  224. #
  225. # @return [Array<String>, nil]
  226. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  227. # @!method initialize(file_ids: nil, type: :auto)
  228. # Some parameter documentations has been truncated, see
  229. # {OpenAI::Models::Responses::Tool::CodeInterpreter::Container::CodeInterpreterToolAuto}
  230. # for more details.
  231. #
  232. # Configuration for a code interpreter container. Optionally specify the IDs of
  233. # the files to run the code on.
  234. #
  235. # @param file_ids [Array<String>] An optional list of uploaded files to make available to your code.
  236. #
  237. # @param type [Symbol, :auto] Always `auto`.
  238. end
  239. # @!method self.variants
  240. # @return [Array(String, OpenAI::Models::Responses::Tool::CodeInterpreter::Container::CodeInterpreterToolAuto)]
  241. end
  242. end
  243. 1 class ImageGeneration < OpenAI::Internal::Type::BaseModel
  244. # @!attribute type
  245. # The type of the image generation tool. Always `image_generation`.
  246. #
  247. # @return [Symbol, :image_generation]
  248. 1 required :type, const: :image_generation
  249. # @!attribute background
  250. # Background type for the generated image. One of `transparent`, `opaque`, or
  251. # `auto`. Default: `auto`.
  252. #
  253. # @return [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Background, nil]
  254. 1 optional :background, enum: -> { OpenAI::Responses::Tool::ImageGeneration::Background }
  255. # @!attribute input_fidelity
  256. # Control how much effort the model will exert to match the style and features,
  257. # especially facial features, of input images. This parameter is only supported
  258. # for `gpt-image-1`. Supports `high` and `low`. Defaults to `low`.
  259. #
  260. # @return [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::InputFidelity, nil]
  261. 1 optional :input_fidelity,
  262. enum: -> {
  263. OpenAI::Responses::Tool::ImageGeneration::InputFidelity
  264. },
  265. nil?: true
  266. # @!attribute input_image_mask
  267. # Optional mask for inpainting. Contains `image_url` (string, optional) and
  268. # `file_id` (string, optional).
  269. #
  270. # @return [OpenAI::Models::Responses::Tool::ImageGeneration::InputImageMask, nil]
  271. 1 optional :input_image_mask, -> { OpenAI::Responses::Tool::ImageGeneration::InputImageMask }
  272. # @!attribute model
  273. # The image generation model to use. Default: `gpt-image-1`.
  274. #
  275. # @return [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Model, nil]
  276. 1 optional :model, enum: -> { OpenAI::Responses::Tool::ImageGeneration::Model }
  277. # @!attribute moderation
  278. # Moderation level for the generated image. Default: `auto`.
  279. #
  280. # @return [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Moderation, nil]
  281. 1 optional :moderation, enum: -> { OpenAI::Responses::Tool::ImageGeneration::Moderation }
  282. # @!attribute output_compression
  283. # Compression level for the output image. Default: 100.
  284. #
  285. # @return [Integer, nil]
  286. 1 optional :output_compression, Integer
  287. # @!attribute output_format
  288. # The output format of the generated image. One of `png`, `webp`, or `jpeg`.
  289. # Default: `png`.
  290. #
  291. # @return [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::OutputFormat, nil]
  292. 1 optional :output_format, enum: -> { OpenAI::Responses::Tool::ImageGeneration::OutputFormat }
  293. # @!attribute partial_images
  294. # Number of partial images to generate in streaming mode, from 0 (default value)
  295. # to 3.
  296. #
  297. # @return [Integer, nil]
  298. 1 optional :partial_images, Integer
  299. # @!attribute quality
  300. # The quality of the generated image. One of `low`, `medium`, `high`, or `auto`.
  301. # Default: `auto`.
  302. #
  303. # @return [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Quality, nil]
  304. 1 optional :quality, enum: -> { OpenAI::Responses::Tool::ImageGeneration::Quality }
  305. # @!attribute size
  306. # The size of the generated image. One of `1024x1024`, `1024x1536`, `1536x1024`,
  307. # or `auto`. Default: `auto`.
  308. #
  309. # @return [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Size, nil]
  310. 1 optional :size, enum: -> { OpenAI::Responses::Tool::ImageGeneration::Size }
  311. # @!method initialize(background: nil, input_fidelity: nil, input_image_mask: nil, model: nil, moderation: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, size: nil, type: :image_generation)
  312. # Some parameter documentations has been truncated, see
  313. # {OpenAI::Models::Responses::Tool::ImageGeneration} for more details.
  314. #
  315. # A tool that generates images using a model like `gpt-image-1`.
  316. #
  317. # @param background [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Background] Background type for the generated image. One of `transparent`,
  318. #
  319. # @param input_fidelity [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::InputFidelity, nil] Control how much effort the model will exert to match the style and features,
  320. #
  321. # @param input_image_mask [OpenAI::Models::Responses::Tool::ImageGeneration::InputImageMask] Optional mask for inpainting. Contains `image_url`
  322. #
  323. # @param model [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Model] The image generation model to use. Default: `gpt-image-1`.
  324. #
  325. # @param moderation [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Moderation] Moderation level for the generated image. Default: `auto`.
  326. #
  327. # @param output_compression [Integer] Compression level for the output image. Default: 100.
  328. #
  329. # @param output_format [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::OutputFormat] The output format of the generated image. One of `png`, `webp`, or
  330. #
  331. # @param partial_images [Integer] Number of partial images to generate in streaming mode, from 0 (default value) t
  332. #
  333. # @param quality [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Quality] The quality of the generated image. One of `low`, `medium`, `high`,
  334. #
  335. # @param size [Symbol, OpenAI::Models::Responses::Tool::ImageGeneration::Size] The size of the generated image. One of `1024x1024`, `1024x1536`,
  336. #
  337. # @param type [Symbol, :image_generation] The type of the image generation tool. Always `image_generation`.
  338. # Background type for the generated image. One of `transparent`, `opaque`, or
  339. # `auto`. Default: `auto`.
  340. #
  341. # @see OpenAI::Models::Responses::Tool::ImageGeneration#background
  342. 1 module Background
  343. 1 extend OpenAI::Internal::Type::Enum
  344. 1 TRANSPARENT = :transparent
  345. 1 OPAQUE = :opaque
  346. 1 AUTO = :auto
  347. # @!method self.values
  348. # @return [Array<Symbol>]
  349. end
  350. # Control how much effort the model will exert to match the style and features,
  351. # especially facial features, of input images. This parameter is only supported
  352. # for `gpt-image-1`. Supports `high` and `low`. Defaults to `low`.
  353. #
  354. # @see OpenAI::Models::Responses::Tool::ImageGeneration#input_fidelity
  355. 1 module InputFidelity
  356. 1 extend OpenAI::Internal::Type::Enum
  357. 1 HIGH = :high
  358. 1 LOW = :low
  359. # @!method self.values
  360. # @return [Array<Symbol>]
  361. end
  362. # @see OpenAI::Models::Responses::Tool::ImageGeneration#input_image_mask
  363. 1 class InputImageMask < OpenAI::Internal::Type::BaseModel
  364. # @!attribute file_id
  365. # File ID for the mask image.
  366. #
  367. # @return [String, nil]
  368. 1 optional :file_id, String
  369. # @!attribute image_url
  370. # Base64-encoded mask image.
  371. #
  372. # @return [String, nil]
  373. 1 optional :image_url, String
  374. # @!method initialize(file_id: nil, image_url: nil)
  375. # Some parameter documentations has been truncated, see
  376. # {OpenAI::Models::Responses::Tool::ImageGeneration::InputImageMask} for more
  377. # details.
  378. #
  379. # Optional mask for inpainting. Contains `image_url` (string, optional) and
  380. # `file_id` (string, optional).
  381. #
  382. # @param file_id [String] File ID for the mask image.
  383. #
  384. # @param image_url [String] Base64-encoded mask image.
  385. end
  386. # The image generation model to use. Default: `gpt-image-1`.
  387. #
  388. # @see OpenAI::Models::Responses::Tool::ImageGeneration#model
  389. 1 module Model
  390. 1 extend OpenAI::Internal::Type::Enum
  391. 1 GPT_IMAGE_1 = :"gpt-image-1"
  392. # @!method self.values
  393. # @return [Array<Symbol>]
  394. end
  395. # Moderation level for the generated image. Default: `auto`.
  396. #
  397. # @see OpenAI::Models::Responses::Tool::ImageGeneration#moderation
  398. 1 module Moderation
  399. 1 extend OpenAI::Internal::Type::Enum
  400. 1 AUTO = :auto
  401. 1 LOW = :low
  402. # @!method self.values
  403. # @return [Array<Symbol>]
  404. end
  405. # The output format of the generated image. One of `png`, `webp`, or `jpeg`.
  406. # Default: `png`.
  407. #
  408. # @see OpenAI::Models::Responses::Tool::ImageGeneration#output_format
  409. 1 module OutputFormat
  410. 1 extend OpenAI::Internal::Type::Enum
  411. 1 PNG = :png
  412. 1 WEBP = :webp
  413. 1 JPEG = :jpeg
  414. # @!method self.values
  415. # @return [Array<Symbol>]
  416. end
  417. # The quality of the generated image. One of `low`, `medium`, `high`, or `auto`.
  418. # Default: `auto`.
  419. #
  420. # @see OpenAI::Models::Responses::Tool::ImageGeneration#quality
  421. 1 module Quality
  422. 1 extend OpenAI::Internal::Type::Enum
  423. 1 LOW = :low
  424. 1 MEDIUM = :medium
  425. 1 HIGH = :high
  426. 1 AUTO = :auto
  427. # @!method self.values
  428. # @return [Array<Symbol>]
  429. end
  430. # The size of the generated image. One of `1024x1024`, `1024x1536`, `1536x1024`,
  431. # or `auto`. Default: `auto`.
  432. #
  433. # @see OpenAI::Models::Responses::Tool::ImageGeneration#size
  434. 1 module Size
  435. 1 extend OpenAI::Internal::Type::Enum
  436. 1 SIZE_1024X1024 = :"1024x1024"
  437. 1 SIZE_1024X1536 = :"1024x1536"
  438. 1 SIZE_1536X1024 = :"1536x1024"
  439. 1 AUTO = :auto
  440. # @!method self.values
  441. # @return [Array<Symbol>]
  442. end
  443. end
  444. 1 class LocalShell < OpenAI::Internal::Type::BaseModel
  445. # @!attribute type
  446. # The type of the local shell tool. Always `local_shell`.
  447. #
  448. # @return [Symbol, :local_shell]
  449. 1 required :type, const: :local_shell
  450. # @!method initialize(type: :local_shell)
  451. # A tool that allows the model to execute shell commands in a local environment.
  452. #
  453. # @param type [Symbol, :local_shell] The type of the local shell tool. Always `local_shell`.
  454. end
  455. # @!method self.variants
  456. # @return [Array(OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool)]
  457. end
  458. end
  459. end
  460. end

openai-ruby/lib/openai/models/responses/tool_choice_function.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ToolChoiceFunction < OpenAI::Internal::Type::BaseModel
  6. # @!attribute name
  7. # The name of the function to call.
  8. #
  9. # @return [String]
  10. 1 required :name, String
  11. # @!attribute type
  12. # For function calling, the type is always `function`.
  13. #
  14. # @return [Symbol, :function]
  15. 1 required :type, const: :function
  16. # @!method initialize(name:, type: :function)
  17. # Use this option to force the model to call a specific function.
  18. #
  19. # @param name [String] The name of the function to call.
  20. #
  21. # @param type [Symbol, :function] For function calling, the type is always `function`.
  22. end
  23. end
  24. end
  25. end

openai-ruby/lib/openai/models/responses/tool_choice_mcp.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ToolChoiceMcp < OpenAI::Internal::Type::BaseModel
  6. # @!attribute server_label
  7. # The label of the MCP server to use.
  8. #
  9. # @return [String]
  10. 1 required :server_label, String
  11. # @!attribute type
  12. # For MCP tools, the type is always `mcp`.
  13. #
  14. # @return [Symbol, :mcp]
  15. 1 required :type, const: :mcp
  16. # @!attribute name
  17. # The name of the tool to call on the server.
  18. #
  19. # @return [String, nil]
  20. 1 optional :name, String, nil?: true
  21. # @!method initialize(server_label:, name: nil, type: :mcp)
  22. # Some parameter documentations has been truncated, see
  23. # {OpenAI::Models::Responses::ToolChoiceMcp} for more details.
  24. #
  25. # Use this option to force the model to call a specific tool on a remote MCP
  26. # server.
  27. #
  28. # @param server_label [String] The label of the MCP server to use.
  29. #
  30. # @param name [String, nil] The name of the tool to call on the server.
  31. #
  32. # @param type [Symbol, :mcp] For MCP tools, the type is always `mcp`.
  33. end
  34. end
  35. end
  36. end

openai-ruby/lib/openai/models/responses/tool_choice_options.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. # Controls which (if any) tool is called by the model.
  6. #
  7. # `none` means the model will not call any tool and instead generates a message.
  8. #
  9. # `auto` means the model can pick between generating a message or calling one or
  10. # more tools.
  11. #
  12. # `required` means the model must call one or more tools.
  13. 1 module ToolChoiceOptions
  14. 1 extend OpenAI::Internal::Type::Enum
  15. 1 NONE = :none
  16. 1 AUTO = :auto
  17. 1 REQUIRED = :required
  18. # @!method self.values
  19. # @return [Array<Symbol>]
  20. end
  21. end
  22. end
  23. end

openai-ruby/lib/openai/models/responses/tool_choice_types.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class ToolChoiceTypes < OpenAI::Internal::Type::BaseModel
  6. # @!attribute type
  7. # The type of hosted tool the model should to use. Learn more about
  8. # [built-in tools](https://platform.openai.com/docs/guides/tools).
  9. #
  10. # Allowed values are:
  11. #
  12. # - `file_search`
  13. # - `web_search_preview`
  14. # - `computer_use_preview`
  15. # - `code_interpreter`
  16. # - `image_generation`
  17. #
  18. # @return [Symbol, OpenAI::Models::Responses::ToolChoiceTypes::Type]
  19. 1 required :type, enum: -> { OpenAI::Responses::ToolChoiceTypes::Type }
  20. # @!method initialize(type:)
  21. # Some parameter documentations has been truncated, see
  22. # {OpenAI::Models::Responses::ToolChoiceTypes} for more details.
  23. #
  24. # Indicates that the model should use a built-in tool to generate a response.
  25. # [Learn more about built-in tools](https://platform.openai.com/docs/guides/tools).
  26. #
  27. # @param type [Symbol, OpenAI::Models::Responses::ToolChoiceTypes::Type] The type of hosted tool the model should to use. Learn more about
  28. # The type of hosted tool the model should to use. Learn more about
  29. # [built-in tools](https://platform.openai.com/docs/guides/tools).
  30. #
  31. # Allowed values are:
  32. #
  33. # - `file_search`
  34. # - `web_search_preview`
  35. # - `computer_use_preview`
  36. # - `code_interpreter`
  37. # - `image_generation`
  38. #
  39. # @see OpenAI::Models::Responses::ToolChoiceTypes#type
  40. 1 module Type
  41. 1 extend OpenAI::Internal::Type::Enum
  42. 1 FILE_SEARCH = :file_search
  43. 1 WEB_SEARCH_PREVIEW = :web_search_preview
  44. 1 COMPUTER_USE_PREVIEW = :computer_use_preview
  45. 1 WEB_SEARCH_PREVIEW_2025_03_11 = :web_search_preview_2025_03_11
  46. 1 IMAGE_GENERATION = :image_generation
  47. 1 CODE_INTERPRETER = :code_interpreter
  48. # @!method self.values
  49. # @return [Array<Symbol>]
  50. end
  51. end
  52. end
  53. end
  54. end

openai-ruby/lib/openai/models/responses/web_search_tool.rb

100.0% lines covered

100.0% branches covered

22 relevant lines. 22 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Responses
  5. 1 class WebSearchTool < OpenAI::Internal::Type::BaseModel
  6. # @!attribute type
  7. # The type of the web search tool. One of `web_search_preview` or
  8. # `web_search_preview_2025_03_11`.
  9. #
  10. # @return [Symbol, OpenAI::Models::Responses::WebSearchTool::Type]
  11. 1 required :type, enum: -> { OpenAI::Responses::WebSearchTool::Type }
  12. # @!attribute search_context_size
  13. # High level guidance for the amount of context window space to use for the
  14. # search. One of `low`, `medium`, or `high`. `medium` is the default.
  15. #
  16. # @return [Symbol, OpenAI::Models::Responses::WebSearchTool::SearchContextSize, nil]
  17. 1 optional :search_context_size, enum: -> { OpenAI::Responses::WebSearchTool::SearchContextSize }
  18. # @!attribute user_location
  19. # The user's location.
  20. #
  21. # @return [OpenAI::Models::Responses::WebSearchTool::UserLocation, nil]
  22. 1 optional :user_location, -> { OpenAI::Responses::WebSearchTool::UserLocation }, nil?: true
  23. # @!method initialize(type:, search_context_size: nil, user_location: nil)
  24. # Some parameter documentations has been truncated, see
  25. # {OpenAI::Models::Responses::WebSearchTool} for more details.
  26. #
  27. # This tool searches the web for relevant results to use in a response. Learn more
  28. # about the
  29. # [web search tool](https://platform.openai.com/docs/guides/tools-web-search).
  30. #
  31. # @param type [Symbol, OpenAI::Models::Responses::WebSearchTool::Type] The type of the web search tool. One of `web_search_preview` or `web_search_prev
  32. #
  33. # @param search_context_size [Symbol, OpenAI::Models::Responses::WebSearchTool::SearchContextSize] High level guidance for the amount of context window space to use for the search
  34. #
  35. # @param user_location [OpenAI::Models::Responses::WebSearchTool::UserLocation, nil] The user's location.
  36. # The type of the web search tool. One of `web_search_preview` or
  37. # `web_search_preview_2025_03_11`.
  38. #
  39. # @see OpenAI::Models::Responses::WebSearchTool#type
  40. 1 module Type
  41. 1 extend OpenAI::Internal::Type::Enum
  42. 1 WEB_SEARCH_PREVIEW = :web_search_preview
  43. 1 WEB_SEARCH_PREVIEW_2025_03_11 = :web_search_preview_2025_03_11
  44. # @!method self.values
  45. # @return [Array<Symbol>]
  46. end
  47. # High level guidance for the amount of context window space to use for the
  48. # search. One of `low`, `medium`, or `high`. `medium` is the default.
  49. #
  50. # @see OpenAI::Models::Responses::WebSearchTool#search_context_size
  51. 1 module SearchContextSize
  52. 1 extend OpenAI::Internal::Type::Enum
  53. 1 LOW = :low
  54. 1 MEDIUM = :medium
  55. 1 HIGH = :high
  56. # @!method self.values
  57. # @return [Array<Symbol>]
  58. end
  59. # @see OpenAI::Models::Responses::WebSearchTool#user_location
  60. 1 class UserLocation < OpenAI::Internal::Type::BaseModel
  61. # @!attribute type
  62. # The type of location approximation. Always `approximate`.
  63. #
  64. # @return [Symbol, :approximate]
  65. 1 required :type, const: :approximate
  66. # @!attribute city
  67. # Free text input for the city of the user, e.g. `San Francisco`.
  68. #
  69. # @return [String, nil]
  70. 1 optional :city, String, nil?: true
  71. # @!attribute country
  72. # The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of
  73. # the user, e.g. `US`.
  74. #
  75. # @return [String, nil]
  76. 1 optional :country, String, nil?: true
  77. # @!attribute region
  78. # Free text input for the region of the user, e.g. `California`.
  79. #
  80. # @return [String, nil]
  81. 1 optional :region, String, nil?: true
  82. # @!attribute timezone
  83. # The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the
  84. # user, e.g. `America/Los_Angeles`.
  85. #
  86. # @return [String, nil]
  87. 1 optional :timezone, String, nil?: true
  88. # @!method initialize(city: nil, country: nil, region: nil, timezone: nil, type: :approximate)
  89. # Some parameter documentations has been truncated, see
  90. # {OpenAI::Models::Responses::WebSearchTool::UserLocation} for more details.
  91. #
  92. # The user's location.
  93. #
  94. # @param city [String, nil] Free text input for the city of the user, e.g. `San Francisco`.
  95. #
  96. # @param country [String, nil] The two-letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1) of t
  97. #
  98. # @param region [String, nil] Free text input for the region of the user, e.g. `California`.
  99. #
  100. # @param timezone [String, nil] The [IANA timezone](https://timeapi.io/documentation/iana-timezones) of the user
  101. #
  102. # @param type [Symbol, :approximate] The type of location approximation. Always `approximate`.
  103. end
  104. end
  105. end
  106. end
  107. end

openai-ruby/lib/openai/models/responses_model.rb

100.0% lines covered

100.0% branches covered

19 relevant lines. 19 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module ResponsesModel
  5. 1 extend OpenAI::Internal::Type::Union
  6. 1 variant String
  7. 1 variant enum: -> { OpenAI::ChatModel }
  8. 1 variant enum: -> { OpenAI::ResponsesModel::ResponsesOnlyModel }
  9. 1 module ResponsesOnlyModel
  10. 1 extend OpenAI::Internal::Type::Enum
  11. 1 O1_PRO = :"o1-pro"
  12. 1 O1_PRO_2025_03_19 = :"o1-pro-2025-03-19"
  13. 1 O3_PRO = :"o3-pro"
  14. 1 O3_PRO_2025_06_10 = :"o3-pro-2025-06-10"
  15. 1 O3_DEEP_RESEARCH = :"o3-deep-research"
  16. 1 O3_DEEP_RESEARCH_2025_06_26 = :"o3-deep-research-2025-06-26"
  17. 1 O4_MINI_DEEP_RESEARCH = :"o4-mini-deep-research"
  18. 1 O4_MINI_DEEP_RESEARCH_2025_06_26 = :"o4-mini-deep-research-2025-06-26"
  19. 1 COMPUTER_USE_PREVIEW = :"computer-use-preview"
  20. 1 COMPUTER_USE_PREVIEW_2025_03_11 = :"computer-use-preview-2025-03-11"
  21. # @!method self.values
  22. # @return [Array<Symbol>]
  23. end
  24. # @!method self.variants
  25. # @return [Array(String, Symbol, OpenAI::Models::ChatModel, Symbol, OpenAI::Models::ResponsesModel::ResponsesOnlyModel)]
  26. end
  27. end
  28. end

openai-ruby/lib/openai/models/static_file_chunking_strategy.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class StaticFileChunkingStrategy < OpenAI::Internal::Type::BaseModel
  5. # @!attribute chunk_overlap_tokens
  6. # The number of tokens that overlap between chunks. The default value is `400`.
  7. #
  8. # Note that the overlap must not exceed half of `max_chunk_size_tokens`.
  9. #
  10. # @return [Integer]
  11. 1 required :chunk_overlap_tokens, Integer
  12. # @!attribute max_chunk_size_tokens
  13. # The maximum number of tokens in each chunk. The default value is `800`. The
  14. # minimum value is `100` and the maximum value is `4096`.
  15. #
  16. # @return [Integer]
  17. 1 required :max_chunk_size_tokens, Integer
  18. # @!method initialize(chunk_overlap_tokens:, max_chunk_size_tokens:)
  19. # Some parameter documentations has been truncated, see
  20. # {OpenAI::Models::StaticFileChunkingStrategy} for more details.
  21. #
  22. # @param chunk_overlap_tokens [Integer] The number of tokens that overlap between chunks. The default value is `400`.
  23. #
  24. # @param max_chunk_size_tokens [Integer] The maximum number of tokens in each chunk. The default value is `800`. The mini
  25. end
  26. end
  27. end

openai-ruby/lib/openai/models/static_file_chunking_strategy_object.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class StaticFileChunkingStrategyObject < OpenAI::Internal::Type::BaseModel
  5. # @!attribute static
  6. #
  7. # @return [OpenAI::Models::StaticFileChunkingStrategy]
  8. 1 required :static, -> { OpenAI::StaticFileChunkingStrategy }
  9. # @!attribute type
  10. # Always `static`.
  11. #
  12. # @return [Symbol, :static]
  13. 1 required :type, const: :static
  14. # @!method initialize(static:, type: :static)
  15. # @param static [OpenAI::Models::StaticFileChunkingStrategy]
  16. #
  17. # @param type [Symbol, :static] Always `static`.
  18. end
  19. end
  20. end

openai-ruby/lib/openai/models/static_file_chunking_strategy_object_param.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 class StaticFileChunkingStrategyObjectParam < OpenAI::Internal::Type::BaseModel
  5. # @!attribute static
  6. #
  7. # @return [OpenAI::Models::StaticFileChunkingStrategy]
  8. 1 required :static, -> { OpenAI::StaticFileChunkingStrategy }
  9. # @!attribute type
  10. # Always `static`.
  11. #
  12. # @return [Symbol, :static]
  13. 1 required :type, const: :static
  14. # @!method initialize(static:, type: :static)
  15. # Customize your own chunking strategy by setting chunk size and chunk overlap.
  16. #
  17. # @param static [OpenAI::Models::StaticFileChunkingStrategy]
  18. #
  19. # @param type [Symbol, :static] Always `static`.
  20. end
  21. end
  22. end

openai-ruby/lib/openai/models/upload.rb

100.0% lines covered

100.0% branches covered

18 relevant lines. 18 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Uploads#create
  5. 1 class Upload < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The Upload unique identifier, which can be referenced in API endpoints.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute bytes
  12. # The intended number of bytes to be uploaded.
  13. #
  14. # @return [Integer]
  15. 1 required :bytes, Integer
  16. # @!attribute created_at
  17. # The Unix timestamp (in seconds) for when the Upload was created.
  18. #
  19. # @return [Integer]
  20. 1 required :created_at, Integer
  21. # @!attribute expires_at
  22. # The Unix timestamp (in seconds) for when the Upload will expire.
  23. #
  24. # @return [Integer]
  25. 1 required :expires_at, Integer
  26. # @!attribute filename
  27. # The name of the file to be uploaded.
  28. #
  29. # @return [String]
  30. 1 required :filename, String
  31. # @!attribute object
  32. # The object type, which is always "upload".
  33. #
  34. # @return [Symbol, :upload]
  35. 1 required :object, const: :upload
  36. # @!attribute purpose
  37. # The intended purpose of the file.
  38. # [Please refer here](https://platform.openai.com/docs/api-reference/files/object#files/object-purpose)
  39. # for acceptable values.
  40. #
  41. # @return [String]
  42. 1 required :purpose, String
  43. # @!attribute status
  44. # The status of the Upload.
  45. #
  46. # @return [Symbol, OpenAI::Models::Upload::Status]
  47. 1 required :status, enum: -> { OpenAI::Upload::Status }
  48. # @!attribute file
  49. # The `File` object represents a document that has been uploaded to OpenAI.
  50. #
  51. # @return [OpenAI::Models::FileObject, nil]
  52. 1 optional :file, -> { OpenAI::FileObject }, nil?: true
  53. # @!method initialize(id:, bytes:, created_at:, expires_at:, filename:, purpose:, status:, file: nil, object: :upload)
  54. # Some parameter documentations has been truncated, see {OpenAI::Models::Upload}
  55. # for more details.
  56. #
  57. # The Upload object can accept byte chunks in the form of Parts.
  58. #
  59. # @param id [String] The Upload unique identifier, which can be referenced in API endpoints.
  60. #
  61. # @param bytes [Integer] The intended number of bytes to be uploaded.
  62. #
  63. # @param created_at [Integer] The Unix timestamp (in seconds) for when the Upload was created.
  64. #
  65. # @param expires_at [Integer] The Unix timestamp (in seconds) for when the Upload will expire.
  66. #
  67. # @param filename [String] The name of the file to be uploaded.
  68. #
  69. # @param purpose [String] The intended purpose of the file. [Please refer here](https://platform.openai.co
  70. #
  71. # @param status [Symbol, OpenAI::Models::Upload::Status] The status of the Upload.
  72. #
  73. # @param file [OpenAI::Models::FileObject, nil] The `File` object represents a document that has been uploaded to OpenAI.
  74. #
  75. # @param object [Symbol, :upload] The object type, which is always "upload".
  76. # The status of the Upload.
  77. #
  78. # @see OpenAI::Models::Upload#status
  79. 1 module Status
  80. 1 extend OpenAI::Internal::Type::Enum
  81. 1 PENDING = :pending
  82. 1 COMPLETED = :completed
  83. 1 CANCELLED = :cancelled
  84. 1 EXPIRED = :expired
  85. # @!method self.values
  86. # @return [Array<Symbol>]
  87. end
  88. end
  89. end
  90. end

openai-ruby/lib/openai/models/upload_cancel_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Uploads#cancel
  5. 1 class UploadCancelParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/upload_complete_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Uploads#complete
  5. 1 class UploadCompleteParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute part_ids
  9. # The ordered list of Part IDs.
  10. #
  11. # @return [Array<String>]
  12. 1 required :part_ids, OpenAI::Internal::Type::ArrayOf[String]
  13. # @!attribute md5
  14. # The optional md5 checksum for the file contents to verify if the bytes uploaded
  15. # matches what you expect.
  16. #
  17. # @return [String, nil]
  18. 1 optional :md5, String
  19. # @!method initialize(part_ids:, md5: nil, request_options: {})
  20. # Some parameter documentations has been truncated, see
  21. # {OpenAI::Models::UploadCompleteParams} for more details.
  22. #
  23. # @param part_ids [Array<String>] The ordered list of Part IDs.
  24. #
  25. # @param md5 [String] The optional md5 checksum for the file contents to verify if the bytes uploaded
  26. #
  27. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  28. end
  29. end
  30. end

openai-ruby/lib/openai/models/upload_create_params.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::Uploads#create
  5. 1 class UploadCreateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute bytes
  9. # The number of bytes in the file you are uploading.
  10. #
  11. # @return [Integer]
  12. 1 required :bytes, Integer
  13. # @!attribute filename
  14. # The name of the file to upload.
  15. #
  16. # @return [String]
  17. 1 required :filename, String
  18. # @!attribute mime_type
  19. # The MIME type of the file.
  20. #
  21. # This must fall within the supported MIME types for your file purpose. See the
  22. # supported MIME types for assistants and vision.
  23. #
  24. # @return [String]
  25. 1 required :mime_type, String
  26. # @!attribute purpose
  27. # The intended purpose of the uploaded file.
  28. #
  29. # See the
  30. # [documentation on File purposes](https://platform.openai.com/docs/api-reference/files/create#files-create-purpose).
  31. #
  32. # @return [Symbol, OpenAI::Models::FilePurpose]
  33. 1 required :purpose, enum: -> { OpenAI::FilePurpose }
  34. # @!method initialize(bytes:, filename:, mime_type:, purpose:, request_options: {})
  35. # Some parameter documentations has been truncated, see
  36. # {OpenAI::Models::UploadCreateParams} for more details.
  37. #
  38. # @param bytes [Integer] The number of bytes in the file you are uploading.
  39. #
  40. # @param filename [String] The name of the file to upload.
  41. #
  42. # @param mime_type [String] The MIME type of the file.
  43. #
  44. # @param purpose [Symbol, OpenAI::Models::FilePurpose] The intended purpose of the uploaded file.
  45. #
  46. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  47. end
  48. end
  49. end

openai-ruby/lib/openai/models/uploads/part_create_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Uploads
  5. # @see OpenAI::Resources::Uploads::Parts#create
  6. 1 class PartCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute data
  10. # The chunk of bytes for this Part.
  11. #
  12. # @return [Pathname, StringIO, IO, String, OpenAI::FilePart]
  13. 1 required :data, OpenAI::Internal::Type::FileInput
  14. # @!method initialize(data:, request_options: {})
  15. # Some parameter documentations has been truncated, see
  16. # {OpenAI::Models::Uploads::PartCreateParams} for more details.
  17. #
  18. # @param data [Pathname, StringIO, IO, String, OpenAI::FilePart] The chunk of bytes for this Part.
  19. #
  20. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  21. end
  22. end
  23. end
  24. end

openai-ruby/lib/openai/models/uploads/upload_part.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Uploads
  5. # @see OpenAI::Resources::Uploads::Parts#create
  6. 1 class UploadPart < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The upload Part unique identifier, which can be referenced in API endpoints.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # The Unix timestamp (in seconds) for when the Part was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute object
  18. # The object type, which is always `upload.part`.
  19. #
  20. # @return [Symbol, :"upload.part"]
  21. 1 required :object, const: :"upload.part"
  22. # @!attribute upload_id
  23. # The ID of the Upload object that this Part was added to.
  24. #
  25. # @return [String]
  26. 1 required :upload_id, String
  27. # @!method initialize(id:, created_at:, upload_id:, object: :"upload.part")
  28. # The upload Part represents a chunk of bytes we can add to an Upload object.
  29. #
  30. # @param id [String] The upload Part unique identifier, which can be referenced in API endpoints.
  31. #
  32. # @param created_at [Integer] The Unix timestamp (in seconds) for when the Part was created.
  33. #
  34. # @param upload_id [String] The ID of the Upload object that this Part was added to.
  35. #
  36. # @param object [Symbol, :"upload.part"] The object type, which is always `upload.part`.
  37. end
  38. end
  39. 1 UploadPart = Uploads::UploadPart
  40. end
  41. end

openai-ruby/lib/openai/models/vector_store.rb

100.0% lines covered

100.0% branches covered

28 relevant lines. 28 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::VectorStores#create
  5. 1 class VectorStore < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The identifier, which can be referenced in API endpoints.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) for when the vector store was created.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute file_counts
  17. #
  18. # @return [OpenAI::Models::VectorStore::FileCounts]
  19. 1 required :file_counts, -> { OpenAI::VectorStore::FileCounts }
  20. # @!attribute last_active_at
  21. # The Unix timestamp (in seconds) for when the vector store was last active.
  22. #
  23. # @return [Integer, nil]
  24. 1 required :last_active_at, Integer, nil?: true
  25. # @!attribute metadata
  26. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  27. # for storing additional information about the object in a structured format, and
  28. # querying for objects via API or the dashboard.
  29. #
  30. # Keys are strings with a maximum length of 64 characters. Values are strings with
  31. # a maximum length of 512 characters.
  32. #
  33. # @return [Hash{Symbol=>String}, nil]
  34. 1 required :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  35. # @!attribute name
  36. # The name of the vector store.
  37. #
  38. # @return [String]
  39. 1 required :name, String
  40. # @!attribute object
  41. # The object type, which is always `vector_store`.
  42. #
  43. # @return [Symbol, :vector_store]
  44. 1 required :object, const: :vector_store
  45. # @!attribute status
  46. # The status of the vector store, which can be either `expired`, `in_progress`, or
  47. # `completed`. A status of `completed` indicates that the vector store is ready
  48. # for use.
  49. #
  50. # @return [Symbol, OpenAI::Models::VectorStore::Status]
  51. 1 required :status, enum: -> { OpenAI::VectorStore::Status }
  52. # @!attribute usage_bytes
  53. # The total number of bytes used by the files in the vector store.
  54. #
  55. # @return [Integer]
  56. 1 required :usage_bytes, Integer
  57. # @!attribute expires_after
  58. # The expiration policy for a vector store.
  59. #
  60. # @return [OpenAI::Models::VectorStore::ExpiresAfter, nil]
  61. 1 optional :expires_after, -> { OpenAI::VectorStore::ExpiresAfter }
  62. # @!attribute expires_at
  63. # The Unix timestamp (in seconds) for when the vector store will expire.
  64. #
  65. # @return [Integer, nil]
  66. 1 optional :expires_at, Integer, nil?: true
  67. # @!method initialize(id:, created_at:, file_counts:, last_active_at:, metadata:, name:, status:, usage_bytes:, expires_after: nil, expires_at: nil, object: :vector_store)
  68. # Some parameter documentations has been truncated, see
  69. # {OpenAI::Models::VectorStore} for more details.
  70. #
  71. # A vector store is a collection of processed files can be used by the
  72. # `file_search` tool.
  73. #
  74. # @param id [String] The identifier, which can be referenced in API endpoints.
  75. #
  76. # @param created_at [Integer] The Unix timestamp (in seconds) for when the vector store was created.
  77. #
  78. # @param file_counts [OpenAI::Models::VectorStore::FileCounts]
  79. #
  80. # @param last_active_at [Integer, nil] The Unix timestamp (in seconds) for when the vector store was last active.
  81. #
  82. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  83. #
  84. # @param name [String] The name of the vector store.
  85. #
  86. # @param status [Symbol, OpenAI::Models::VectorStore::Status] The status of the vector store, which can be either `expired`, `in_progress`, or
  87. #
  88. # @param usage_bytes [Integer] The total number of bytes used by the files in the vector store.
  89. #
  90. # @param expires_after [OpenAI::Models::VectorStore::ExpiresAfter] The expiration policy for a vector store.
  91. #
  92. # @param expires_at [Integer, nil] The Unix timestamp (in seconds) for when the vector store will expire.
  93. #
  94. # @param object [Symbol, :vector_store] The object type, which is always `vector_store`.
  95. # @see OpenAI::Models::VectorStore#file_counts
  96. 1 class FileCounts < OpenAI::Internal::Type::BaseModel
  97. # @!attribute cancelled
  98. # The number of files that were cancelled.
  99. #
  100. # @return [Integer]
  101. 1 required :cancelled, Integer
  102. # @!attribute completed
  103. # The number of files that have been successfully processed.
  104. #
  105. # @return [Integer]
  106. 1 required :completed, Integer
  107. # @!attribute failed
  108. # The number of files that have failed to process.
  109. #
  110. # @return [Integer]
  111. 1 required :failed, Integer
  112. # @!attribute in_progress
  113. # The number of files that are currently being processed.
  114. #
  115. # @return [Integer]
  116. 1 required :in_progress, Integer
  117. # @!attribute total
  118. # The total number of files.
  119. #
  120. # @return [Integer]
  121. 1 required :total, Integer
  122. # @!method initialize(cancelled:, completed:, failed:, in_progress:, total:)
  123. # @param cancelled [Integer] The number of files that were cancelled.
  124. #
  125. # @param completed [Integer] The number of files that have been successfully processed.
  126. #
  127. # @param failed [Integer] The number of files that have failed to process.
  128. #
  129. # @param in_progress [Integer] The number of files that are currently being processed.
  130. #
  131. # @param total [Integer] The total number of files.
  132. end
  133. # The status of the vector store, which can be either `expired`, `in_progress`, or
  134. # `completed`. A status of `completed` indicates that the vector store is ready
  135. # for use.
  136. #
  137. # @see OpenAI::Models::VectorStore#status
  138. 1 module Status
  139. 1 extend OpenAI::Internal::Type::Enum
  140. 1 EXPIRED = :expired
  141. 1 IN_PROGRESS = :in_progress
  142. 1 COMPLETED = :completed
  143. # @!method self.values
  144. # @return [Array<Symbol>]
  145. end
  146. # @see OpenAI::Models::VectorStore#expires_after
  147. 1 class ExpiresAfter < OpenAI::Internal::Type::BaseModel
  148. # @!attribute anchor
  149. # Anchor timestamp after which the expiration policy applies. Supported anchors:
  150. # `last_active_at`.
  151. #
  152. # @return [Symbol, :last_active_at]
  153. 1 required :anchor, const: :last_active_at
  154. # @!attribute days
  155. # The number of days after the anchor time that the vector store will expire.
  156. #
  157. # @return [Integer]
  158. 1 required :days, Integer
  159. # @!method initialize(days:, anchor: :last_active_at)
  160. # Some parameter documentations has been truncated, see
  161. # {OpenAI::Models::VectorStore::ExpiresAfter} for more details.
  162. #
  163. # The expiration policy for a vector store.
  164. #
  165. # @param days [Integer] The number of days after the anchor time that the vector store will expire.
  166. #
  167. # @param anchor [Symbol, :last_active_at] Anchor timestamp after which the expiration policy applies. Supported anchors: `
  168. end
  169. end
  170. end
  171. end

openai-ruby/lib/openai/models/vector_store_create_params.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::VectorStores#create
  5. 1 class VectorStoreCreateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute chunking_strategy
  9. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  10. # strategy. Only applicable if `file_ids` is non-empty.
  11. #
  12. # @return [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam, nil]
  13. 1 optional :chunking_strategy, union: -> { OpenAI::FileChunkingStrategyParam }
  14. # @!attribute expires_after
  15. # The expiration policy for a vector store.
  16. #
  17. # @return [OpenAI::Models::VectorStoreCreateParams::ExpiresAfter, nil]
  18. 1 optional :expires_after, -> { OpenAI::VectorStoreCreateParams::ExpiresAfter }
  19. # @!attribute file_ids
  20. # A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
  21. # the vector store should use. Useful for tools like `file_search` that can access
  22. # files.
  23. #
  24. # @return [Array<String>, nil]
  25. 1 optional :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  26. # @!attribute metadata
  27. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  28. # for storing additional information about the object in a structured format, and
  29. # querying for objects via API or the dashboard.
  30. #
  31. # Keys are strings with a maximum length of 64 characters. Values are strings with
  32. # a maximum length of 512 characters.
  33. #
  34. # @return [Hash{Symbol=>String}, nil]
  35. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  36. # @!attribute name
  37. # The name of the vector store.
  38. #
  39. # @return [String, nil]
  40. 1 optional :name, String
  41. # @!method initialize(chunking_strategy: nil, expires_after: nil, file_ids: nil, metadata: nil, name: nil, request_options: {})
  42. # Some parameter documentations has been truncated, see
  43. # {OpenAI::Models::VectorStoreCreateParams} for more details.
  44. #
  45. # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  46. #
  47. # @param expires_after [OpenAI::Models::VectorStoreCreateParams::ExpiresAfter] The expiration policy for a vector store.
  48. #
  49. # @param file_ids [Array<String>] A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
  50. #
  51. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  52. #
  53. # @param name [String] The name of the vector store.
  54. #
  55. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  56. 1 class ExpiresAfter < OpenAI::Internal::Type::BaseModel
  57. # @!attribute anchor
  58. # Anchor timestamp after which the expiration policy applies. Supported anchors:
  59. # `last_active_at`.
  60. #
  61. # @return [Symbol, :last_active_at]
  62. 1 required :anchor, const: :last_active_at
  63. # @!attribute days
  64. # The number of days after the anchor time that the vector store will expire.
  65. #
  66. # @return [Integer]
  67. 1 required :days, Integer
  68. # @!method initialize(days:, anchor: :last_active_at)
  69. # Some parameter documentations has been truncated, see
  70. # {OpenAI::Models::VectorStoreCreateParams::ExpiresAfter} for more details.
  71. #
  72. # The expiration policy for a vector store.
  73. #
  74. # @param days [Integer] The number of days after the anchor time that the vector store will expire.
  75. #
  76. # @param anchor [Symbol, :last_active_at] Anchor timestamp after which the expiration policy applies. Supported anchors: `
  77. end
  78. end
  79. end
  80. end

openai-ruby/lib/openai/models/vector_store_delete_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::VectorStores#delete
  5. 1 class VectorStoreDeleteParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/vector_store_deleted.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::VectorStores#delete
  5. 1 class VectorStoreDeleted < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. #
  8. # @return [String]
  9. 1 required :id, String
  10. # @!attribute deleted
  11. #
  12. # @return [Boolean]
  13. 1 required :deleted, OpenAI::Internal::Type::Boolean
  14. # @!attribute object
  15. #
  16. # @return [Symbol, :"vector_store.deleted"]
  17. 1 required :object, const: :"vector_store.deleted"
  18. # @!method initialize(id:, deleted:, object: :"vector_store.deleted")
  19. # @param id [String]
  20. # @param deleted [Boolean]
  21. # @param object [Symbol, :"vector_store.deleted"]
  22. end
  23. end
  24. end

openai-ruby/lib/openai/models/vector_store_list_params.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::VectorStores#list
  5. 1 class VectorStoreListParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute after
  9. # A cursor for use in pagination. `after` is an object ID that defines your place
  10. # in the list. For instance, if you make a list request and receive 100 objects,
  11. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  12. # fetch the next page of the list.
  13. #
  14. # @return [String, nil]
  15. 1 optional :after, String
  16. # @!attribute before
  17. # A cursor for use in pagination. `before` is an object ID that defines your place
  18. # in the list. For instance, if you make a list request and receive 100 objects,
  19. # starting with obj_foo, your subsequent call can include before=obj_foo in order
  20. # to fetch the previous page of the list.
  21. #
  22. # @return [String, nil]
  23. 1 optional :before, String
  24. # @!attribute limit
  25. # A limit on the number of objects to be returned. Limit can range between 1 and
  26. # 100, and the default is 20.
  27. #
  28. # @return [Integer, nil]
  29. 1 optional :limit, Integer
  30. # @!attribute order
  31. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  32. # order and `desc` for descending order.
  33. #
  34. # @return [Symbol, OpenAI::Models::VectorStoreListParams::Order, nil]
  35. 1 optional :order, enum: -> { OpenAI::VectorStoreListParams::Order }
  36. # @!method initialize(after: nil, before: nil, limit: nil, order: nil, request_options: {})
  37. # Some parameter documentations has been truncated, see
  38. # {OpenAI::Models::VectorStoreListParams} for more details.
  39. #
  40. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  41. #
  42. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  43. #
  44. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  45. #
  46. # @param order [Symbol, OpenAI::Models::VectorStoreListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  47. #
  48. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  49. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  50. # order and `desc` for descending order.
  51. 1 module Order
  52. 1 extend OpenAI::Internal::Type::Enum
  53. 1 ASC = :asc
  54. 1 DESC = :desc
  55. # @!method self.values
  56. # @return [Array<Symbol>]
  57. end
  58. end
  59. end
  60. end

openai-ruby/lib/openai/models/vector_store_retrieve_params.rb

100.0% lines covered

100.0% branches covered

5 relevant lines. 5 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::VectorStores#retrieve
  5. 1 class VectorStoreRetrieveParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!method initialize(request_options: {})
  9. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  10. end
  11. end
  12. end

openai-ruby/lib/openai/models/vector_store_search_params.rb

100.0% lines covered

100.0% branches covered

26 relevant lines. 26 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::VectorStores#search
  5. 1 class VectorStoreSearchParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute query
  9. # A query string for a search
  10. #
  11. # @return [String, Array<String>]
  12. 1 required :query, union: -> { OpenAI::VectorStoreSearchParams::Query }
  13. # @!attribute filters
  14. # A filter to apply based on file attributes.
  15. #
  16. # @return [OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter, nil]
  17. 1 optional :filters, union: -> { OpenAI::VectorStoreSearchParams::Filters }
  18. # @!attribute max_num_results
  19. # The maximum number of results to return. This number should be between 1 and 50
  20. # inclusive.
  21. #
  22. # @return [Integer, nil]
  23. 1 optional :max_num_results, Integer
  24. # @!attribute ranking_options
  25. # Ranking options for search.
  26. #
  27. # @return [OpenAI::Models::VectorStoreSearchParams::RankingOptions, nil]
  28. 1 optional :ranking_options, -> { OpenAI::VectorStoreSearchParams::RankingOptions }
  29. # @!attribute rewrite_query
  30. # Whether to rewrite the natural language query for vector search.
  31. #
  32. # @return [Boolean, nil]
  33. 1 optional :rewrite_query, OpenAI::Internal::Type::Boolean
  34. # @!method initialize(query:, filters: nil, max_num_results: nil, ranking_options: nil, rewrite_query: nil, request_options: {})
  35. # Some parameter documentations has been truncated, see
  36. # {OpenAI::Models::VectorStoreSearchParams} for more details.
  37. #
  38. # @param query [String, Array<String>] A query string for a search
  39. #
  40. # @param filters [OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter] A filter to apply based on file attributes.
  41. #
  42. # @param max_num_results [Integer] The maximum number of results to return. This number should be between 1 and 50
  43. #
  44. # @param ranking_options [OpenAI::Models::VectorStoreSearchParams::RankingOptions] Ranking options for search.
  45. #
  46. # @param rewrite_query [Boolean] Whether to rewrite the natural language query for vector search.
  47. #
  48. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  49. # A query string for a search
  50. 1 module Query
  51. 1 extend OpenAI::Internal::Type::Union
  52. 1 variant String
  53. 1 variant -> { OpenAI::Models::VectorStoreSearchParams::Query::StringArray }
  54. # @!method self.variants
  55. # @return [Array(String, Array<String>)]
  56. # @type [OpenAI::Internal::Type::Converter]
  57. 1 StringArray = OpenAI::Internal::Type::ArrayOf[String]
  58. end
  59. # A filter to apply based on file attributes.
  60. 1 module Filters
  61. 1 extend OpenAI::Internal::Type::Union
  62. # A filter used to compare a specified attribute key to a given value using a defined comparison operation.
  63. 1 variant -> { OpenAI::ComparisonFilter }
  64. # Combine multiple filters using `and` or `or`.
  65. 1 variant -> { OpenAI::CompoundFilter }
  66. # @!method self.variants
  67. # @return [Array(OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter)]
  68. end
  69. 1 class RankingOptions < OpenAI::Internal::Type::BaseModel
  70. # @!attribute ranker
  71. #
  72. # @return [Symbol, OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker, nil]
  73. 1 optional :ranker, enum: -> { OpenAI::VectorStoreSearchParams::RankingOptions::Ranker }
  74. # @!attribute score_threshold
  75. #
  76. # @return [Float, nil]
  77. 1 optional :score_threshold, Float
  78. # @!method initialize(ranker: nil, score_threshold: nil)
  79. # Ranking options for search.
  80. #
  81. # @param ranker [Symbol, OpenAI::Models::VectorStoreSearchParams::RankingOptions::Ranker]
  82. # @param score_threshold [Float]
  83. # @see OpenAI::Models::VectorStoreSearchParams::RankingOptions#ranker
  84. 1 module Ranker
  85. 1 extend OpenAI::Internal::Type::Enum
  86. 1 AUTO = :auto
  87. 1 DEFAULT_2024_11_15 = :"default-2024-11-15"
  88. # @!method self.values
  89. # @return [Array<Symbol>]
  90. end
  91. end
  92. end
  93. end
  94. end

openai-ruby/lib/openai/models/vector_store_search_response.rb

90.48% lines covered

100.0% branches covered

21 relevant lines. 19 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::VectorStores#search
  5. 1 class VectorStoreSearchResponse < OpenAI::Internal::Type::BaseModel
  6. # @!attribute attributes
  7. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  8. # for storing additional information about the object in a structured format, and
  9. # querying for objects via API or the dashboard. Keys are strings with a maximum
  10. # length of 64 characters. Values are strings with a maximum length of 512
  11. # characters, booleans, or numbers.
  12. #
  13. # @return [Hash{Symbol=>String, Float, Boolean}, nil]
  14. 1 required :attributes,
  15. -> { OpenAI::Internal::Type::HashOf[union: OpenAI::Models::VectorStoreSearchResponse::Attribute] },
  16. nil?: true
  17. # @!attribute content
  18. # Content chunks from the file.
  19. #
  20. # @return [Array<OpenAI::Models::VectorStoreSearchResponse::Content>]
  21. 1 required :content,
  22. -> { OpenAI::Internal::Type::ArrayOf[OpenAI::Models::VectorStoreSearchResponse::Content] }
  23. # @!attribute file_id
  24. # The ID of the vector store file.
  25. #
  26. # @return [String]
  27. 1 required :file_id, String
  28. # @!attribute filename
  29. # The name of the vector store file.
  30. #
  31. # @return [String]
  32. 1 required :filename, String
  33. # @!attribute score
  34. # The similarity score for the result.
  35. #
  36. # @return [Float]
  37. 1 required :score, Float
  38. # @!method initialize(attributes:, content:, file_id:, filename:, score:)
  39. # Some parameter documentations has been truncated, see
  40. # {OpenAI::Models::VectorStoreSearchResponse} for more details.
  41. #
  42. # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  43. #
  44. # @param content [Array<OpenAI::Models::VectorStoreSearchResponse::Content>] Content chunks from the file.
  45. #
  46. # @param file_id [String] The ID of the vector store file.
  47. #
  48. # @param filename [String] The name of the vector store file.
  49. #
  50. # @param score [Float] The similarity score for the result.
  51. 1 module Attribute
  52. 1 extend OpenAI::Internal::Type::Union
  53. 1 variant String
  54. 1 variant Float
  55. 1 variant OpenAI::Internal::Type::Boolean
  56. # @!method self.variants
  57. # @return [Array(String, Float, Boolean)]
  58. end
  59. 1 class Content < OpenAI::Internal::Type::BaseModel
  60. # @!attribute text
  61. # The text content returned from search.
  62. #
  63. # @return [String]
  64. 1 required :text, String
  65. # @!attribute type
  66. # The type of content.
  67. #
  68. # @return [Symbol, OpenAI::Models::VectorStoreSearchResponse::Content::Type]
  69. 1 required :type, enum: -> { OpenAI::Models::VectorStoreSearchResponse::Content::Type }
  70. # @!method initialize(text:, type:)
  71. # @param text [String] The text content returned from search.
  72. #
  73. # @param type [Symbol, OpenAI::Models::VectorStoreSearchResponse::Content::Type] The type of content.
  74. # The type of content.
  75. #
  76. # @see OpenAI::Models::VectorStoreSearchResponse::Content#type
  77. 1 module Type
  78. 1 extend OpenAI::Internal::Type::Enum
  79. 1 TEXT = :text
  80. # @!method self.values
  81. # @return [Array<Symbol>]
  82. end
  83. end
  84. end
  85. end
  86. end

openai-ruby/lib/openai/models/vector_store_update_params.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. # @see OpenAI::Resources::VectorStores#update
  5. 1 class VectorStoreUpdateParams < OpenAI::Internal::Type::BaseModel
  6. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  7. 1 include OpenAI::Internal::Type::RequestParameters
  8. # @!attribute expires_after
  9. # The expiration policy for a vector store.
  10. #
  11. # @return [OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter, nil]
  12. 1 optional :expires_after, -> { OpenAI::VectorStoreUpdateParams::ExpiresAfter }, nil?: true
  13. # @!attribute metadata
  14. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  15. # for storing additional information about the object in a structured format, and
  16. # querying for objects via API or the dashboard.
  17. #
  18. # Keys are strings with a maximum length of 64 characters. Values are strings with
  19. # a maximum length of 512 characters.
  20. #
  21. # @return [Hash{Symbol=>String}, nil]
  22. 1 optional :metadata, OpenAI::Internal::Type::HashOf[String], nil?: true
  23. # @!attribute name
  24. # The name of the vector store.
  25. #
  26. # @return [String, nil]
  27. 1 optional :name, String, nil?: true
  28. # @!method initialize(expires_after: nil, metadata: nil, name: nil, request_options: {})
  29. # Some parameter documentations has been truncated, see
  30. # {OpenAI::Models::VectorStoreUpdateParams} for more details.
  31. #
  32. # @param expires_after [OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter, nil] The expiration policy for a vector store.
  33. #
  34. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  35. #
  36. # @param name [String, nil] The name of the vector store.
  37. #
  38. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  39. 1 class ExpiresAfter < OpenAI::Internal::Type::BaseModel
  40. # @!attribute anchor
  41. # Anchor timestamp after which the expiration policy applies. Supported anchors:
  42. # `last_active_at`.
  43. #
  44. # @return [Symbol, :last_active_at]
  45. 1 required :anchor, const: :last_active_at
  46. # @!attribute days
  47. # The number of days after the anchor time that the vector store will expire.
  48. #
  49. # @return [Integer]
  50. 1 required :days, Integer
  51. # @!method initialize(days:, anchor: :last_active_at)
  52. # Some parameter documentations has been truncated, see
  53. # {OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter} for more details.
  54. #
  55. # The expiration policy for a vector store.
  56. #
  57. # @param days [Integer] The number of days after the anchor time that the vector store will expire.
  58. #
  59. # @param anchor [Symbol, :last_active_at] Anchor timestamp after which the expiration policy applies. Supported anchors: `
  60. end
  61. end
  62. end
  63. end

openai-ruby/lib/openai/models/vector_stores/file_batch_cancel_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::FileBatches#cancel
  6. 1 class FileBatchCancelParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute vector_store_id
  10. #
  11. # @return [String]
  12. 1 required :vector_store_id, String
  13. # @!method initialize(vector_store_id:, request_options: {})
  14. # @param vector_store_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/vector_stores/file_batch_create_params.rb

93.33% lines covered

100.0% branches covered

15 relevant lines. 14 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::FileBatches#create
  6. 1 class FileBatchCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute file_ids
  10. # A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
  11. # the vector store should use. Useful for tools like `file_search` that can access
  12. # files.
  13. #
  14. # @return [Array<String>]
  15. 1 required :file_ids, OpenAI::Internal::Type::ArrayOf[String]
  16. # @!attribute attributes
  17. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  18. # for storing additional information about the object in a structured format, and
  19. # querying for objects via API or the dashboard. Keys are strings with a maximum
  20. # length of 64 characters. Values are strings with a maximum length of 512
  21. # characters, booleans, or numbers.
  22. #
  23. # @return [Hash{Symbol=>String, Float, Boolean}, nil]
  24. 1 optional :attributes,
  25. -> {
  26. OpenAI::Internal::Type::HashOf[union: OpenAI::VectorStores::FileBatchCreateParams::Attribute]
  27. },
  28. nil?: true
  29. # @!attribute chunking_strategy
  30. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  31. # strategy. Only applicable if `file_ids` is non-empty.
  32. #
  33. # @return [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam, nil]
  34. 1 optional :chunking_strategy, union: -> { OpenAI::FileChunkingStrategyParam }
  35. # @!method initialize(file_ids:, attributes: nil, chunking_strategy: nil, request_options: {})
  36. # Some parameter documentations has been truncated, see
  37. # {OpenAI::Models::VectorStores::FileBatchCreateParams} for more details.
  38. #
  39. # @param file_ids [Array<String>] A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
  40. #
  41. # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  42. #
  43. # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  44. #
  45. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  46. 1 module Attribute
  47. 1 extend OpenAI::Internal::Type::Union
  48. 1 variant String
  49. 1 variant Float
  50. 1 variant OpenAI::Internal::Type::Boolean
  51. # @!method self.variants
  52. # @return [Array(String, Float, Boolean)]
  53. end
  54. end
  55. end
  56. end
  57. end

openai-ruby/lib/openai/models/vector_stores/file_batch_list_files_params.rb

100.0% lines covered

100.0% branches covered

22 relevant lines. 22 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::FileBatches#list_files
  6. 1 class FileBatchListFilesParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute vector_store_id
  10. #
  11. # @return [String]
  12. 1 required :vector_store_id, String
  13. # @!attribute after
  14. # A cursor for use in pagination. `after` is an object ID that defines your place
  15. # in the list. For instance, if you make a list request and receive 100 objects,
  16. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  17. # fetch the next page of the list.
  18. #
  19. # @return [String, nil]
  20. 1 optional :after, String
  21. # @!attribute before
  22. # A cursor for use in pagination. `before` is an object ID that defines your place
  23. # in the list. For instance, if you make a list request and receive 100 objects,
  24. # starting with obj_foo, your subsequent call can include before=obj_foo in order
  25. # to fetch the previous page of the list.
  26. #
  27. # @return [String, nil]
  28. 1 optional :before, String
  29. # @!attribute filter
  30. # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
  31. #
  32. # @return [Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter, nil]
  33. 1 optional :filter, enum: -> { OpenAI::VectorStores::FileBatchListFilesParams::Filter }
  34. # @!attribute limit
  35. # A limit on the number of objects to be returned. Limit can range between 1 and
  36. # 100, and the default is 20.
  37. #
  38. # @return [Integer, nil]
  39. 1 optional :limit, Integer
  40. # @!attribute order
  41. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  42. # order and `desc` for descending order.
  43. #
  44. # @return [Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Order, nil]
  45. 1 optional :order, enum: -> { OpenAI::VectorStores::FileBatchListFilesParams::Order }
  46. # @!method initialize(vector_store_id:, after: nil, before: nil, filter: nil, limit: nil, order: nil, request_options: {})
  47. # Some parameter documentations has been truncated, see
  48. # {OpenAI::Models::VectorStores::FileBatchListFilesParams} for more details.
  49. #
  50. # @param vector_store_id [String]
  51. #
  52. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  53. #
  54. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  55. #
  56. # @param filter [Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter] Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
  57. #
  58. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  59. #
  60. # @param order [Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  61. #
  62. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  63. # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
  64. 1 module Filter
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 IN_PROGRESS = :in_progress
  67. 1 COMPLETED = :completed
  68. 1 FAILED = :failed
  69. 1 CANCELLED = :cancelled
  70. # @!method self.values
  71. # @return [Array<Symbol>]
  72. end
  73. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  74. # order and `desc` for descending order.
  75. 1 module Order
  76. 1 extend OpenAI::Internal::Type::Enum
  77. 1 ASC = :asc
  78. 1 DESC = :desc
  79. # @!method self.values
  80. # @return [Array<Symbol>]
  81. end
  82. end
  83. end
  84. end
  85. end

openai-ruby/lib/openai/models/vector_stores/file_batch_retrieve_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::FileBatches#retrieve
  6. 1 class FileBatchRetrieveParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute vector_store_id
  10. #
  11. # @return [String]
  12. 1 required :vector_store_id, String
  13. # @!method initialize(vector_store_id:, request_options: {})
  14. # @param vector_store_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/vector_stores/file_content_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::Files#content
  6. 1 class FileContentParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute vector_store_id
  10. #
  11. # @return [String]
  12. 1 required :vector_store_id, String
  13. # @!method initialize(vector_store_id:, request_options: {})
  14. # @param vector_store_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/vector_stores/file_content_response.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::Files#content
  6. 1 class FileContentResponse < OpenAI::Internal::Type::BaseModel
  7. # @!attribute text
  8. # The text content
  9. #
  10. # @return [String, nil]
  11. 1 optional :text, String
  12. # @!attribute type
  13. # The content type (currently only `"text"`)
  14. #
  15. # @return [String, nil]
  16. 1 optional :type, String
  17. # @!method initialize(text: nil, type: nil)
  18. # @param text [String] The text content
  19. #
  20. # @param type [String] The content type (currently only `"text"`)
  21. end
  22. end
  23. end
  24. end

openai-ruby/lib/openai/models/vector_stores/file_create_params.rb

93.33% lines covered

100.0% branches covered

15 relevant lines. 14 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::Files#create
  6. 1 class FileCreateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute file_id
  10. # A [File](https://platform.openai.com/docs/api-reference/files) ID that the
  11. # vector store should use. Useful for tools like `file_search` that can access
  12. # files.
  13. #
  14. # @return [String]
  15. 1 required :file_id, String
  16. # @!attribute attributes
  17. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  18. # for storing additional information about the object in a structured format, and
  19. # querying for objects via API or the dashboard. Keys are strings with a maximum
  20. # length of 64 characters. Values are strings with a maximum length of 512
  21. # characters, booleans, or numbers.
  22. #
  23. # @return [Hash{Symbol=>String, Float, Boolean}, nil]
  24. 1 optional :attributes,
  25. -> {
  26. OpenAI::Internal::Type::HashOf[union: OpenAI::VectorStores::FileCreateParams::Attribute]
  27. },
  28. nil?: true
  29. # @!attribute chunking_strategy
  30. # The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  31. # strategy. Only applicable if `file_ids` is non-empty.
  32. #
  33. # @return [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam, nil]
  34. 1 optional :chunking_strategy, union: -> { OpenAI::FileChunkingStrategyParam }
  35. # @!method initialize(file_id:, attributes: nil, chunking_strategy: nil, request_options: {})
  36. # Some parameter documentations has been truncated, see
  37. # {OpenAI::Models::VectorStores::FileCreateParams} for more details.
  38. #
  39. # @param file_id [String] A [File](https://platform.openai.com/docs/api-reference/files) ID that the vecto
  40. #
  41. # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  42. #
  43. # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  44. #
  45. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  46. 1 module Attribute
  47. 1 extend OpenAI::Internal::Type::Union
  48. 1 variant String
  49. 1 variant Float
  50. 1 variant OpenAI::Internal::Type::Boolean
  51. # @!method self.variants
  52. # @return [Array(String, Float, Boolean)]
  53. end
  54. end
  55. end
  56. end
  57. end

openai-ruby/lib/openai/models/vector_stores/file_delete_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::Files#delete
  6. 1 class FileDeleteParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute vector_store_id
  10. #
  11. # @return [String]
  12. 1 required :vector_store_id, String
  13. # @!method initialize(vector_store_id:, request_options: {})
  14. # @param vector_store_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/vector_stores/file_list_params.rb

100.0% lines covered

100.0% branches covered

21 relevant lines. 21 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::Files#list
  6. 1 class FileListParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute after
  10. # A cursor for use in pagination. `after` is an object ID that defines your place
  11. # in the list. For instance, if you make a list request and receive 100 objects,
  12. # ending with obj_foo, your subsequent call can include after=obj_foo in order to
  13. # fetch the next page of the list.
  14. #
  15. # @return [String, nil]
  16. 1 optional :after, String
  17. # @!attribute before
  18. # A cursor for use in pagination. `before` is an object ID that defines your place
  19. # in the list. For instance, if you make a list request and receive 100 objects,
  20. # starting with obj_foo, your subsequent call can include before=obj_foo in order
  21. # to fetch the previous page of the list.
  22. #
  23. # @return [String, nil]
  24. 1 optional :before, String
  25. # @!attribute filter
  26. # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
  27. #
  28. # @return [Symbol, OpenAI::Models::VectorStores::FileListParams::Filter, nil]
  29. 1 optional :filter, enum: -> { OpenAI::VectorStores::FileListParams::Filter }
  30. # @!attribute limit
  31. # A limit on the number of objects to be returned. Limit can range between 1 and
  32. # 100, and the default is 20.
  33. #
  34. # @return [Integer, nil]
  35. 1 optional :limit, Integer
  36. # @!attribute order
  37. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  38. # order and `desc` for descending order.
  39. #
  40. # @return [Symbol, OpenAI::Models::VectorStores::FileListParams::Order, nil]
  41. 1 optional :order, enum: -> { OpenAI::VectorStores::FileListParams::Order }
  42. # @!method initialize(after: nil, before: nil, filter: nil, limit: nil, order: nil, request_options: {})
  43. # Some parameter documentations has been truncated, see
  44. # {OpenAI::Models::VectorStores::FileListParams} for more details.
  45. #
  46. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  47. #
  48. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  49. #
  50. # @param filter [Symbol, OpenAI::Models::VectorStores::FileListParams::Filter] Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
  51. #
  52. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  53. #
  54. # @param order [Symbol, OpenAI::Models::VectorStores::FileListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  55. #
  56. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  57. # Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
  58. 1 module Filter
  59. 1 extend OpenAI::Internal::Type::Enum
  60. 1 IN_PROGRESS = :in_progress
  61. 1 COMPLETED = :completed
  62. 1 FAILED = :failed
  63. 1 CANCELLED = :cancelled
  64. # @!method self.values
  65. # @return [Array<Symbol>]
  66. end
  67. # Sort order by the `created_at` timestamp of the objects. `asc` for ascending
  68. # order and `desc` for descending order.
  69. 1 module Order
  70. 1 extend OpenAI::Internal::Type::Enum
  71. 1 ASC = :asc
  72. 1 DESC = :desc
  73. # @!method self.values
  74. # @return [Array<Symbol>]
  75. end
  76. end
  77. end
  78. end
  79. end

openai-ruby/lib/openai/models/vector_stores/file_retrieve_params.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::Files#retrieve
  6. 1 class FileRetrieveParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute vector_store_id
  10. #
  11. # @return [String]
  12. 1 required :vector_store_id, String
  13. # @!method initialize(vector_store_id:, request_options: {})
  14. # @param vector_store_id [String]
  15. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/models/vector_stores/file_update_params.rb

92.86% lines covered

100.0% branches covered

14 relevant lines. 13 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::Files#update
  6. 1 class FileUpdateParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!attribute vector_store_id
  10. #
  11. # @return [String]
  12. 1 required :vector_store_id, String
  13. # @!attribute attributes
  14. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  15. # for storing additional information about the object in a structured format, and
  16. # querying for objects via API or the dashboard. Keys are strings with a maximum
  17. # length of 64 characters. Values are strings with a maximum length of 512
  18. # characters, booleans, or numbers.
  19. #
  20. # @return [Hash{Symbol=>String, Float, Boolean}, nil]
  21. 1 required :attributes,
  22. -> {
  23. OpenAI::Internal::Type::HashOf[union: OpenAI::VectorStores::FileUpdateParams::Attribute]
  24. },
  25. nil?: true
  26. # @!method initialize(vector_store_id:, attributes:, request_options: {})
  27. # Some parameter documentations has been truncated, see
  28. # {OpenAI::Models::VectorStores::FileUpdateParams} for more details.
  29. #
  30. # @param vector_store_id [String]
  31. #
  32. # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  33. #
  34. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  35. 1 module Attribute
  36. 1 extend OpenAI::Internal::Type::Union
  37. 1 variant String
  38. 1 variant Float
  39. 1 variant OpenAI::Internal::Type::Boolean
  40. # @!method self.variants
  41. # @return [Array(String, Float, Boolean)]
  42. end
  43. end
  44. end
  45. end
  46. end

openai-ruby/lib/openai/models/vector_stores/vector_store_file.rb

97.06% lines covered

100.0% branches covered

34 relevant lines. 33 lines covered and 1 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::Files#create
  6. 1 class VectorStoreFile < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The identifier, which can be referenced in API endpoints.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # The Unix timestamp (in seconds) for when the vector store file was created.
  14. #
  15. # @return [Integer]
  16. 1 required :created_at, Integer
  17. # @!attribute last_error
  18. # The last error associated with this vector store file. Will be `null` if there
  19. # are no errors.
  20. #
  21. # @return [OpenAI::Models::VectorStores::VectorStoreFile::LastError, nil]
  22. 1 required :last_error, -> { OpenAI::VectorStores::VectorStoreFile::LastError }, nil?: true
  23. # @!attribute object
  24. # The object type, which is always `vector_store.file`.
  25. #
  26. # @return [Symbol, :"vector_store.file"]
  27. 1 required :object, const: :"vector_store.file"
  28. # @!attribute status
  29. # The status of the vector store file, which can be either `in_progress`,
  30. # `completed`, `cancelled`, or `failed`. The status `completed` indicates that the
  31. # vector store file is ready for use.
  32. #
  33. # @return [Symbol, OpenAI::Models::VectorStores::VectorStoreFile::Status]
  34. 1 required :status, enum: -> { OpenAI::VectorStores::VectorStoreFile::Status }
  35. # @!attribute usage_bytes
  36. # The total vector store usage in bytes. Note that this may be different from the
  37. # original file size.
  38. #
  39. # @return [Integer]
  40. 1 required :usage_bytes, Integer
  41. # @!attribute vector_store_id
  42. # The ID of the
  43. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  44. # that the [File](https://platform.openai.com/docs/api-reference/files) is
  45. # attached to.
  46. #
  47. # @return [String]
  48. 1 required :vector_store_id, String
  49. # @!attribute attributes
  50. # Set of 16 key-value pairs that can be attached to an object. This can be useful
  51. # for storing additional information about the object in a structured format, and
  52. # querying for objects via API or the dashboard. Keys are strings with a maximum
  53. # length of 64 characters. Values are strings with a maximum length of 512
  54. # characters, booleans, or numbers.
  55. #
  56. # @return [Hash{Symbol=>String, Float, Boolean}, nil]
  57. 1 optional :attributes,
  58. -> {
  59. OpenAI::Internal::Type::HashOf[union: OpenAI::VectorStores::VectorStoreFile::Attribute]
  60. },
  61. nil?: true
  62. # @!attribute chunking_strategy
  63. # The strategy used to chunk the file.
  64. #
  65. # @return [OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject, nil]
  66. 1 optional :chunking_strategy, union: -> { OpenAI::FileChunkingStrategy }
  67. # @!method initialize(id:, created_at:, last_error:, status:, usage_bytes:, vector_store_id:, attributes: nil, chunking_strategy: nil, object: :"vector_store.file")
  68. # Some parameter documentations has been truncated, see
  69. # {OpenAI::Models::VectorStores::VectorStoreFile} for more details.
  70. #
  71. # A list of files attached to a vector store.
  72. #
  73. # @param id [String] The identifier, which can be referenced in API endpoints.
  74. #
  75. # @param created_at [Integer] The Unix timestamp (in seconds) for when the vector store file was created.
  76. #
  77. # @param last_error [OpenAI::Models::VectorStores::VectorStoreFile::LastError, nil] The last error associated with this vector store file. Will be `null` if there a
  78. #
  79. # @param status [Symbol, OpenAI::Models::VectorStores::VectorStoreFile::Status] The status of the vector store file, which can be either `in_progress`, `complet
  80. #
  81. # @param usage_bytes [Integer] The total vector store usage in bytes. Note that this may be different from the
  82. #
  83. # @param vector_store_id [String] The ID of the [vector store](https://platform.openai.com/docs/api-reference/vect
  84. #
  85. # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  86. #
  87. # @param chunking_strategy [OpenAI::Models::StaticFileChunkingStrategyObject, OpenAI::Models::OtherFileChunkingStrategyObject] The strategy used to chunk the file.
  88. #
  89. # @param object [Symbol, :"vector_store.file"] The object type, which is always `vector_store.file`.
  90. # @see OpenAI::Models::VectorStores::VectorStoreFile#last_error
  91. 1 class LastError < OpenAI::Internal::Type::BaseModel
  92. # @!attribute code
  93. # One of `server_error` or `rate_limit_exceeded`.
  94. #
  95. # @return [Symbol, OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code]
  96. 1 required :code, enum: -> { OpenAI::VectorStores::VectorStoreFile::LastError::Code }
  97. # @!attribute message
  98. # A human-readable description of the error.
  99. #
  100. # @return [String]
  101. 1 required :message, String
  102. # @!method initialize(code:, message:)
  103. # The last error associated with this vector store file. Will be `null` if there
  104. # are no errors.
  105. #
  106. # @param code [Symbol, OpenAI::Models::VectorStores::VectorStoreFile::LastError::Code] One of `server_error` or `rate_limit_exceeded`.
  107. #
  108. # @param message [String] A human-readable description of the error.
  109. # One of `server_error` or `rate_limit_exceeded`.
  110. #
  111. # @see OpenAI::Models::VectorStores::VectorStoreFile::LastError#code
  112. 1 module Code
  113. 1 extend OpenAI::Internal::Type::Enum
  114. 1 SERVER_ERROR = :server_error
  115. 1 UNSUPPORTED_FILE = :unsupported_file
  116. 1 INVALID_FILE = :invalid_file
  117. # @!method self.values
  118. # @return [Array<Symbol>]
  119. end
  120. end
  121. # The status of the vector store file, which can be either `in_progress`,
  122. # `completed`, `cancelled`, or `failed`. The status `completed` indicates that the
  123. # vector store file is ready for use.
  124. #
  125. # @see OpenAI::Models::VectorStores::VectorStoreFile#status
  126. 1 module Status
  127. 1 extend OpenAI::Internal::Type::Enum
  128. 1 IN_PROGRESS = :in_progress
  129. 1 COMPLETED = :completed
  130. 1 CANCELLED = :cancelled
  131. 1 FAILED = :failed
  132. # @!method self.values
  133. # @return [Array<Symbol>]
  134. end
  135. 1 module Attribute
  136. 1 extend OpenAI::Internal::Type::Union
  137. 1 variant String
  138. 1 variant Float
  139. 1 variant OpenAI::Internal::Type::Boolean
  140. # @!method self.variants
  141. # @return [Array(String, Float, Boolean)]
  142. end
  143. end
  144. end
  145. 1 VectorStoreFile = VectorStores::VectorStoreFile
  146. end
  147. end

openai-ruby/lib/openai/models/vector_stores/vector_store_file_batch.rb

100.0% lines covered

100.0% branches covered

23 relevant lines. 23 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::FileBatches#create
  6. 1 class VectorStoreFileBatch < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. # The identifier, which can be referenced in API endpoints.
  9. #
  10. # @return [String]
  11. 1 required :id, String
  12. # @!attribute created_at
  13. # The Unix timestamp (in seconds) for when the vector store files batch was
  14. # created.
  15. #
  16. # @return [Integer]
  17. 1 required :created_at, Integer
  18. # @!attribute file_counts
  19. #
  20. # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts]
  21. 1 required :file_counts, -> { OpenAI::VectorStores::VectorStoreFileBatch::FileCounts }
  22. # @!attribute object
  23. # The object type, which is always `vector_store.file_batch`.
  24. #
  25. # @return [Symbol, :"vector_store.files_batch"]
  26. 1 required :object, const: :"vector_store.files_batch"
  27. # @!attribute status
  28. # The status of the vector store files batch, which can be either `in_progress`,
  29. # `completed`, `cancelled` or `failed`.
  30. #
  31. # @return [Symbol, OpenAI::Models::VectorStores::VectorStoreFileBatch::Status]
  32. 1 required :status, enum: -> { OpenAI::VectorStores::VectorStoreFileBatch::Status }
  33. # @!attribute vector_store_id
  34. # The ID of the
  35. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object)
  36. # that the [File](https://platform.openai.com/docs/api-reference/files) is
  37. # attached to.
  38. #
  39. # @return [String]
  40. 1 required :vector_store_id, String
  41. # @!method initialize(id:, created_at:, file_counts:, status:, vector_store_id:, object: :"vector_store.files_batch")
  42. # Some parameter documentations has been truncated, see
  43. # {OpenAI::Models::VectorStores::VectorStoreFileBatch} for more details.
  44. #
  45. # A batch of files attached to a vector store.
  46. #
  47. # @param id [String] The identifier, which can be referenced in API endpoints.
  48. #
  49. # @param created_at [Integer] The Unix timestamp (in seconds) for when the vector store files batch was create
  50. #
  51. # @param file_counts [OpenAI::Models::VectorStores::VectorStoreFileBatch::FileCounts]
  52. #
  53. # @param status [Symbol, OpenAI::Models::VectorStores::VectorStoreFileBatch::Status] The status of the vector store files batch, which can be either `in_progress`, `
  54. #
  55. # @param vector_store_id [String] The ID of the [vector store](https://platform.openai.com/docs/api-reference/vect
  56. #
  57. # @param object [Symbol, :"vector_store.files_batch"] The object type, which is always `vector_store.file_batch`.
  58. # @see OpenAI::Models::VectorStores::VectorStoreFileBatch#file_counts
  59. 1 class FileCounts < OpenAI::Internal::Type::BaseModel
  60. # @!attribute cancelled
  61. # The number of files that where cancelled.
  62. #
  63. # @return [Integer]
  64. 1 required :cancelled, Integer
  65. # @!attribute completed
  66. # The number of files that have been processed.
  67. #
  68. # @return [Integer]
  69. 1 required :completed, Integer
  70. # @!attribute failed
  71. # The number of files that have failed to process.
  72. #
  73. # @return [Integer]
  74. 1 required :failed, Integer
  75. # @!attribute in_progress
  76. # The number of files that are currently being processed.
  77. #
  78. # @return [Integer]
  79. 1 required :in_progress, Integer
  80. # @!attribute total
  81. # The total number of files.
  82. #
  83. # @return [Integer]
  84. 1 required :total, Integer
  85. # @!method initialize(cancelled:, completed:, failed:, in_progress:, total:)
  86. # @param cancelled [Integer] The number of files that where cancelled.
  87. #
  88. # @param completed [Integer] The number of files that have been processed.
  89. #
  90. # @param failed [Integer] The number of files that have failed to process.
  91. #
  92. # @param in_progress [Integer] The number of files that are currently being processed.
  93. #
  94. # @param total [Integer] The total number of files.
  95. end
  96. # The status of the vector store files batch, which can be either `in_progress`,
  97. # `completed`, `cancelled` or `failed`.
  98. #
  99. # @see OpenAI::Models::VectorStores::VectorStoreFileBatch#status
  100. 1 module Status
  101. 1 extend OpenAI::Internal::Type::Enum
  102. 1 IN_PROGRESS = :in_progress
  103. 1 COMPLETED = :completed
  104. 1 CANCELLED = :cancelled
  105. 1 FAILED = :failed
  106. # @!method self.values
  107. # @return [Array<Symbol>]
  108. end
  109. end
  110. end
  111. 1 VectorStoreFileBatch = VectorStores::VectorStoreFileBatch
  112. end
  113. end

openai-ruby/lib/openai/models/vector_stores/vector_store_file_deleted.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module VectorStores
  5. # @see OpenAI::Resources::VectorStores::Files#delete
  6. 1 class VectorStoreFileDeleted < OpenAI::Internal::Type::BaseModel
  7. # @!attribute id
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute deleted
  12. #
  13. # @return [Boolean]
  14. 1 required :deleted, OpenAI::Internal::Type::Boolean
  15. # @!attribute object
  16. #
  17. # @return [Symbol, :"vector_store.file.deleted"]
  18. 1 required :object, const: :"vector_store.file.deleted"
  19. # @!method initialize(id:, deleted:, object: :"vector_store.file.deleted")
  20. # @param id [String]
  21. # @param deleted [Boolean]
  22. # @param object [Symbol, :"vector_store.file.deleted"]
  23. end
  24. end
  25. 1 VectorStoreFileDeleted = VectorStores::VectorStoreFileDeleted
  26. end
  27. end

openai-ruby/lib/openai/models/webhooks/batch_cancelled_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class BatchCancelledWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the batch API request was cancelled.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::BatchCancelledWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::BatchCancelledWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `batch.cancelled`.
  23. #
  24. # @return [Symbol, :"batch.cancelled"]
  25. 1 required :type, const: :"batch.cancelled"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::BatchCancelledWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::BatchCancelledWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"batch.cancelled")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::BatchCancelledWebhookEvent} for more details.
  34. #
  35. # Sent when a batch API request has been cancelled.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the batch API request was cancelled.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::BatchCancelledWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::BatchCancelledWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"batch.cancelled"] The type of the event. Always `batch.cancelled`.
  46. # @see OpenAI::Models::Webhooks::BatchCancelledWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the batch API request.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::BatchCancelledWebhookEvent::Data} for more details.
  56. #
  57. # Event data payload.
  58. #
  59. # @param id [String] The unique ID of the batch API request.
  60. end
  61. # The object of the event. Always `event`.
  62. #
  63. # @see OpenAI::Models::Webhooks::BatchCancelledWebhookEvent#object
  64. 1 module Object
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 EVENT = :event
  67. # @!method self.values
  68. # @return [Array<Symbol>]
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/webhooks/batch_completed_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class BatchCompletedWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the batch API request was completed.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::BatchCompletedWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::BatchCompletedWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `batch.completed`.
  23. #
  24. # @return [Symbol, :"batch.completed"]
  25. 1 required :type, const: :"batch.completed"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::BatchCompletedWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::BatchCompletedWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"batch.completed")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::BatchCompletedWebhookEvent} for more details.
  34. #
  35. # Sent when a batch API request has been completed.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the batch API request was completed.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::BatchCompletedWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::BatchCompletedWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"batch.completed"] The type of the event. Always `batch.completed`.
  46. # @see OpenAI::Models::Webhooks::BatchCompletedWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the batch API request.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::BatchCompletedWebhookEvent::Data} for more details.
  56. #
  57. # Event data payload.
  58. #
  59. # @param id [String] The unique ID of the batch API request.
  60. end
  61. # The object of the event. Always `event`.
  62. #
  63. # @see OpenAI::Models::Webhooks::BatchCompletedWebhookEvent#object
  64. 1 module Object
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 EVENT = :event
  67. # @!method self.values
  68. # @return [Array<Symbol>]
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/webhooks/batch_expired_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class BatchExpiredWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the batch API request expired.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::BatchExpiredWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::BatchExpiredWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `batch.expired`.
  23. #
  24. # @return [Symbol, :"batch.expired"]
  25. 1 required :type, const: :"batch.expired"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::BatchExpiredWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::BatchExpiredWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"batch.expired")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::BatchExpiredWebhookEvent} for more details.
  34. #
  35. # Sent when a batch API request has expired.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the batch API request expired.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::BatchExpiredWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::BatchExpiredWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"batch.expired"] The type of the event. Always `batch.expired`.
  46. # @see OpenAI::Models::Webhooks::BatchExpiredWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the batch API request.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::BatchExpiredWebhookEvent::Data} for more details.
  56. #
  57. # Event data payload.
  58. #
  59. # @param id [String] The unique ID of the batch API request.
  60. end
  61. # The object of the event. Always `event`.
  62. #
  63. # @see OpenAI::Models::Webhooks::BatchExpiredWebhookEvent#object
  64. 1 module Object
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 EVENT = :event
  67. # @!method self.values
  68. # @return [Array<Symbol>]
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/webhooks/batch_failed_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class BatchFailedWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the batch API request failed.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::BatchFailedWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::BatchFailedWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `batch.failed`.
  23. #
  24. # @return [Symbol, :"batch.failed"]
  25. 1 required :type, const: :"batch.failed"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::BatchFailedWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::BatchFailedWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"batch.failed")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::BatchFailedWebhookEvent} for more details.
  34. #
  35. # Sent when a batch API request has failed.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the batch API request failed.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::BatchFailedWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::BatchFailedWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"batch.failed"] The type of the event. Always `batch.failed`.
  46. # @see OpenAI::Models::Webhooks::BatchFailedWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the batch API request.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::BatchFailedWebhookEvent::Data} for more details.
  56. #
  57. # Event data payload.
  58. #
  59. # @param id [String] The unique ID of the batch API request.
  60. end
  61. # The object of the event. Always `event`.
  62. #
  63. # @see OpenAI::Models::Webhooks::BatchFailedWebhookEvent#object
  64. 1 module Object
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 EVENT = :event
  67. # @!method self.values
  68. # @return [Array<Symbol>]
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/webhooks/eval_run_canceled_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class EvalRunCanceledWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the eval run was canceled.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::EvalRunCanceledWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `eval.run.canceled`.
  23. #
  24. # @return [Symbol, :"eval.run.canceled"]
  25. 1 required :type, const: :"eval.run.canceled"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::EvalRunCanceledWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"eval.run.canceled")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent} for more details.
  34. #
  35. # Sent when an eval run has been canceled.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the eval run was canceled.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"eval.run.canceled"] The type of the event. Always `eval.run.canceled`.
  46. # @see OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the eval run.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent::Data} for more details.
  56. #
  57. # Event data payload.
  58. #
  59. # @param id [String] The unique ID of the eval run.
  60. end
  61. # The object of the event. Always `event`.
  62. #
  63. # @see OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent#object
  64. 1 module Object
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 EVENT = :event
  67. # @!method self.values
  68. # @return [Array<Symbol>]
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/webhooks/eval_run_failed_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class EvalRunFailedWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the eval run failed.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::EvalRunFailedWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `eval.run.failed`.
  23. #
  24. # @return [Symbol, :"eval.run.failed"]
  25. 1 required :type, const: :"eval.run.failed"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::EvalRunFailedWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"eval.run.failed")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent} for more details.
  34. #
  35. # Sent when an eval run has failed.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the eval run failed.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"eval.run.failed"] The type of the event. Always `eval.run.failed`.
  46. # @see OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the eval run.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent::Data} for more details.
  56. #
  57. # Event data payload.
  58. #
  59. # @param id [String] The unique ID of the eval run.
  60. end
  61. # The object of the event. Always `event`.
  62. #
  63. # @see OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent#object
  64. 1 module Object
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 EVENT = :event
  67. # @!method self.values
  68. # @return [Array<Symbol>]
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/webhooks/eval_run_succeeded_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class EvalRunSucceededWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the eval run succeeded.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::EvalRunSucceededWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `eval.run.succeeded`.
  23. #
  24. # @return [Symbol, :"eval.run.succeeded"]
  25. 1 required :type, const: :"eval.run.succeeded"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::EvalRunSucceededWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"eval.run.succeeded")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent} for more details.
  34. #
  35. # Sent when an eval run has succeeded.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the eval run succeeded.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"eval.run.succeeded"] The type of the event. Always `eval.run.succeeded`.
  46. # @see OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the eval run.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent::Data} for more details.
  56. #
  57. # Event data payload.
  58. #
  59. # @param id [String] The unique ID of the eval run.
  60. end
  61. # The object of the event. Always `event`.
  62. #
  63. # @see OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent#object
  64. 1 module Object
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 EVENT = :event
  67. # @!method self.values
  68. # @return [Array<Symbol>]
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/webhooks/fine_tuning_job_cancelled_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class FineTuningJobCancelledWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the fine-tuning job was cancelled.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::FineTuningJobCancelledWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `fine_tuning.job.cancelled`.
  23. #
  24. # @return [Symbol, :"fine_tuning.job.cancelled"]
  25. 1 required :type, const: :"fine_tuning.job.cancelled"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::FineTuningJobCancelledWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"fine_tuning.job.cancelled")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent} for more details.
  34. #
  35. # Sent when a fine-tuning job has been cancelled.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the fine-tuning job was cancelled.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"fine_tuning.job.cancelled"] The type of the event. Always `fine_tuning.job.cancelled`.
  46. # @see OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the fine-tuning job.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent::Data} for more
  56. # details.
  57. #
  58. # Event data payload.
  59. #
  60. # @param id [String] The unique ID of the fine-tuning job.
  61. end
  62. # The object of the event. Always `event`.
  63. #
  64. # @see OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent#object
  65. 1 module Object
  66. 1 extend OpenAI::Internal::Type::Enum
  67. 1 EVENT = :event
  68. # @!method self.values
  69. # @return [Array<Symbol>]
  70. end
  71. end
  72. end
  73. end
  74. end

openai-ruby/lib/openai/models/webhooks/fine_tuning_job_failed_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class FineTuningJobFailedWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the fine-tuning job failed.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::FineTuningJobFailedWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `fine_tuning.job.failed`.
  23. #
  24. # @return [Symbol, :"fine_tuning.job.failed"]
  25. 1 required :type, const: :"fine_tuning.job.failed"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::FineTuningJobFailedWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"fine_tuning.job.failed")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent} for more details.
  34. #
  35. # Sent when a fine-tuning job has failed.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the fine-tuning job failed.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"fine_tuning.job.failed"] The type of the event. Always `fine_tuning.job.failed`.
  46. # @see OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the fine-tuning job.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent::Data} for more
  56. # details.
  57. #
  58. # Event data payload.
  59. #
  60. # @param id [String] The unique ID of the fine-tuning job.
  61. end
  62. # The object of the event. Always `event`.
  63. #
  64. # @see OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent#object
  65. 1 module Object
  66. 1 extend OpenAI::Internal::Type::Enum
  67. 1 EVENT = :event
  68. # @!method self.values
  69. # @return [Array<Symbol>]
  70. end
  71. end
  72. end
  73. end
  74. end

openai-ruby/lib/openai/models/webhooks/fine_tuning_job_succeeded_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class FineTuningJobSucceededWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the fine-tuning job succeeded.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::FineTuningJobSucceededWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `fine_tuning.job.succeeded`.
  23. #
  24. # @return [Symbol, :"fine_tuning.job.succeeded"]
  25. 1 required :type, const: :"fine_tuning.job.succeeded"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::FineTuningJobSucceededWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"fine_tuning.job.succeeded")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent} for more details.
  34. #
  35. # Sent when a fine-tuning job has succeeded.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the fine-tuning job succeeded.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"fine_tuning.job.succeeded"] The type of the event. Always `fine_tuning.job.succeeded`.
  46. # @see OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the fine-tuning job.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent::Data} for more
  56. # details.
  57. #
  58. # Event data payload.
  59. #
  60. # @param id [String] The unique ID of the fine-tuning job.
  61. end
  62. # The object of the event. Always `event`.
  63. #
  64. # @see OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent#object
  65. 1 module Object
  66. 1 extend OpenAI::Internal::Type::Enum
  67. 1 EVENT = :event
  68. # @!method self.values
  69. # @return [Array<Symbol>]
  70. end
  71. end
  72. end
  73. end
  74. end

openai-ruby/lib/openai/models/webhooks/response_cancelled_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class ResponseCancelledWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the model response was cancelled.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::ResponseCancelledWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `response.cancelled`.
  23. #
  24. # @return [Symbol, :"response.cancelled"]
  25. 1 required :type, const: :"response.cancelled"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::ResponseCancelledWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"response.cancelled")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent} for more details.
  34. #
  35. # Sent when a background response has been cancelled.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the model response was cancelled.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"response.cancelled"] The type of the event. Always `response.cancelled`.
  46. # @see OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the model response.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent::Data} for more
  56. # details.
  57. #
  58. # Event data payload.
  59. #
  60. # @param id [String] The unique ID of the model response.
  61. end
  62. # The object of the event. Always `event`.
  63. #
  64. # @see OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent#object
  65. 1 module Object
  66. 1 extend OpenAI::Internal::Type::Enum
  67. 1 EVENT = :event
  68. # @!method self.values
  69. # @return [Array<Symbol>]
  70. end
  71. end
  72. end
  73. end
  74. end

openai-ruby/lib/openai/models/webhooks/response_completed_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class ResponseCompletedWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the model response was completed.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::ResponseCompletedWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `response.completed`.
  23. #
  24. # @return [Symbol, :"response.completed"]
  25. 1 required :type, const: :"response.completed"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::ResponseCompletedWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"response.completed")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent} for more details.
  34. #
  35. # Sent when a background response has been completed.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the model response was completed.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"response.completed"] The type of the event. Always `response.completed`.
  46. # @see OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the model response.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent::Data} for more
  56. # details.
  57. #
  58. # Event data payload.
  59. #
  60. # @param id [String] The unique ID of the model response.
  61. end
  62. # The object of the event. Always `event`.
  63. #
  64. # @see OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent#object
  65. 1 module Object
  66. 1 extend OpenAI::Internal::Type::Enum
  67. 1 EVENT = :event
  68. # @!method self.values
  69. # @return [Array<Symbol>]
  70. end
  71. end
  72. end
  73. end
  74. end

openai-ruby/lib/openai/models/webhooks/response_failed_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class ResponseFailedWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the model response failed.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::ResponseFailedWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::ResponseFailedWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `response.failed`.
  23. #
  24. # @return [Symbol, :"response.failed"]
  25. 1 required :type, const: :"response.failed"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::ResponseFailedWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::ResponseFailedWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"response.failed")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::ResponseFailedWebhookEvent} for more details.
  34. #
  35. # Sent when a background response has failed.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the model response failed.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::ResponseFailedWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::ResponseFailedWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"response.failed"] The type of the event. Always `response.failed`.
  46. # @see OpenAI::Models::Webhooks::ResponseFailedWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the model response.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::ResponseFailedWebhookEvent::Data} for more details.
  56. #
  57. # Event data payload.
  58. #
  59. # @param id [String] The unique ID of the model response.
  60. end
  61. # The object of the event. Always `event`.
  62. #
  63. # @see OpenAI::Models::Webhooks::ResponseFailedWebhookEvent#object
  64. 1 module Object
  65. 1 extend OpenAI::Internal::Type::Enum
  66. 1 EVENT = :event
  67. # @!method self.values
  68. # @return [Array<Symbol>]
  69. end
  70. end
  71. end
  72. end
  73. end

openai-ruby/lib/openai/models/webhooks/response_incomplete_webhook_event.rb

100.0% lines covered

100.0% branches covered

14 relevant lines. 14 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. 1 class ResponseIncompleteWebhookEvent < OpenAI::Internal::Type::BaseModel
  6. # @!attribute id
  7. # The unique ID of the event.
  8. #
  9. # @return [String]
  10. 1 required :id, String
  11. # @!attribute created_at
  12. # The Unix timestamp (in seconds) of when the model response was interrupted.
  13. #
  14. # @return [Integer]
  15. 1 required :created_at, Integer
  16. # @!attribute data
  17. # Event data payload.
  18. #
  19. # @return [OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent::Data]
  20. 1 required :data, -> { OpenAI::Webhooks::ResponseIncompleteWebhookEvent::Data }
  21. # @!attribute type
  22. # The type of the event. Always `response.incomplete`.
  23. #
  24. # @return [Symbol, :"response.incomplete"]
  25. 1 required :type, const: :"response.incomplete"
  26. # @!attribute object
  27. # The object of the event. Always `event`.
  28. #
  29. # @return [Symbol, OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent::Object, nil]
  30. 1 optional :object, enum: -> { OpenAI::Webhooks::ResponseIncompleteWebhookEvent::Object }
  31. # @!method initialize(id:, created_at:, data:, object: nil, type: :"response.incomplete")
  32. # Some parameter documentations has been truncated, see
  33. # {OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent} for more details.
  34. #
  35. # Sent when a background response has been interrupted.
  36. #
  37. # @param id [String] The unique ID of the event.
  38. #
  39. # @param created_at [Integer] The Unix timestamp (in seconds) of when the model response was interrupted.
  40. #
  41. # @param data [OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent::Data] Event data payload.
  42. #
  43. # @param object [Symbol, OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent::Object] The object of the event. Always `event`.
  44. #
  45. # @param type [Symbol, :"response.incomplete"] The type of the event. Always `response.incomplete`.
  46. # @see OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent#data
  47. 1 class Data < OpenAI::Internal::Type::BaseModel
  48. # @!attribute id
  49. # The unique ID of the model response.
  50. #
  51. # @return [String]
  52. 1 required :id, String
  53. # @!method initialize(id:)
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent::Data} for more
  56. # details.
  57. #
  58. # Event data payload.
  59. #
  60. # @param id [String] The unique ID of the model response.
  61. end
  62. # The object of the event. Always `event`.
  63. #
  64. # @see OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent#object
  65. 1 module Object
  66. 1 extend OpenAI::Internal::Type::Enum
  67. 1 EVENT = :event
  68. # @!method self.values
  69. # @return [Array<Symbol>]
  70. end
  71. end
  72. end
  73. end
  74. end

openai-ruby/lib/openai/models/webhooks/unwrap_webhook_event.rb

100.0% lines covered

100.0% branches covered

20 relevant lines. 20 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. # Sent when a batch API request has been cancelled.
  6. 1 module UnwrapWebhookEvent
  7. 1 extend OpenAI::Internal::Type::Union
  8. 1 discriminator :type
  9. # Sent when a batch API request has been cancelled.
  10. 1 variant :"batch.cancelled", -> { OpenAI::Webhooks::BatchCancelledWebhookEvent }
  11. # Sent when a batch API request has been completed.
  12. 1 variant :"batch.completed", -> { OpenAI::Webhooks::BatchCompletedWebhookEvent }
  13. # Sent when a batch API request has expired.
  14. 1 variant :"batch.expired", -> { OpenAI::Webhooks::BatchExpiredWebhookEvent }
  15. # Sent when a batch API request has failed.
  16. 1 variant :"batch.failed", -> { OpenAI::Webhooks::BatchFailedWebhookEvent }
  17. # Sent when an eval run has been canceled.
  18. 1 variant :"eval.run.canceled", -> { OpenAI::Webhooks::EvalRunCanceledWebhookEvent }
  19. # Sent when an eval run has failed.
  20. 1 variant :"eval.run.failed", -> { OpenAI::Webhooks::EvalRunFailedWebhookEvent }
  21. # Sent when an eval run has succeeded.
  22. 1 variant :"eval.run.succeeded", -> { OpenAI::Webhooks::EvalRunSucceededWebhookEvent }
  23. # Sent when a fine-tuning job has been cancelled.
  24. 1 variant :"fine_tuning.job.cancelled", -> { OpenAI::Webhooks::FineTuningJobCancelledWebhookEvent }
  25. # Sent when a fine-tuning job has failed.
  26. 1 variant :"fine_tuning.job.failed", -> { OpenAI::Webhooks::FineTuningJobFailedWebhookEvent }
  27. # Sent when a fine-tuning job has succeeded.
  28. 1 variant :"fine_tuning.job.succeeded", -> { OpenAI::Webhooks::FineTuningJobSucceededWebhookEvent }
  29. # Sent when a background response has been cancelled.
  30. 1 variant :"response.cancelled", -> { OpenAI::Webhooks::ResponseCancelledWebhookEvent }
  31. # Sent when a background response has been completed.
  32. 1 variant :"response.completed", -> { OpenAI::Webhooks::ResponseCompletedWebhookEvent }
  33. # Sent when a background response has failed.
  34. 1 variant :"response.failed", -> { OpenAI::Webhooks::ResponseFailedWebhookEvent }
  35. # Sent when a background response has been interrupted.
  36. 1 variant :"response.incomplete", -> { OpenAI::Webhooks::ResponseIncompleteWebhookEvent }
  37. # @!method self.variants
  38. # @return [Array(OpenAI::Models::Webhooks::BatchCancelledWebhookEvent, OpenAI::Models::Webhooks::BatchCompletedWebhookEvent, OpenAI::Models::Webhooks::BatchExpiredWebhookEvent, OpenAI::Models::Webhooks::BatchFailedWebhookEvent, OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent, OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent, OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent, OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent, OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent, OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent, OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent, OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent, OpenAI::Models::Webhooks::ResponseFailedWebhookEvent, OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent)]
  39. end
  40. end
  41. end
  42. end

openai-ruby/lib/openai/models/webhooks/webhook_unwrap_params.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Models
  4. 1 module Webhooks
  5. # @see OpenAI::Resources::Webhooks#unwrap
  6. 1 class WebhookUnwrapParams < OpenAI::Internal::Type::BaseModel
  7. 1 extend OpenAI::Internal::Type::RequestParameters::Converter
  8. 1 include OpenAI::Internal::Type::RequestParameters
  9. # @!method initialize(request_options: {})
  10. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  11. end
  12. end
  13. end
  14. end

openai-ruby/lib/openai/request_options.rb

75.0% lines covered

25.0% branches covered

16 relevant lines. 12 lines covered and 4 lines missed.
4 total branches, 1 branches covered and 3 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. # Specify HTTP behaviour to use for a specific request. These options supplement
  4. # or override those provided at the client level.
  5. #
  6. # When making a request, you can pass an actual {RequestOptions} instance, or
  7. # simply pass a Hash with symbol keys matching the attributes on this class.
  8. 1 class RequestOptions < OpenAI::Internal::Type::BaseModel
  9. # @api private
  10. #
  11. # @param opts [OpenAI::RequestOptions, Hash{Symbol=>Object}]
  12. #
  13. # @raise [ArgumentError]
  14. 1 def self.validate!(opts)
  15. case opts
  16. 2 in: 2 in OpenAI::RequestOptions | Hash
  17. 2 opts.to_h.each_key do |k|
  18. else: 0 then: 0 unless fields.include?(k)
  19. raise ArgumentError.new("Request `opts` keys must be one of #{fields.keys}, got #{k.inspect}")
  20. end
  21. end
  22. else: 0 else
  23. raise ArgumentError.new("Request `opts` must be a Hash or RequestOptions, got #{opts.inspect}")
  24. end
  25. end
  26. # @!attribute idempotency_key
  27. # Idempotency key to send with request and all associated retries. Will only be
  28. # sent for write requests.
  29. #
  30. # @return [String, nil]
  31. 1 optional :idempotency_key, String
  32. # @!attribute extra_query
  33. # Extra query params to send with the request. These are `.merge`’d into any
  34. # `query` given at the client level.
  35. #
  36. # @return [Hash{String=>Array<String>, String, nil}, nil]
  37. 1 optional :extra_query, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::ArrayOf[String]]
  38. # @!attribute extra_headers
  39. # Extra headers to send with the request. These are `.merged`’d into any
  40. # `extra_headers` given at the client level.
  41. #
  42. # @return [Hash{String=>String, nil}, nil]
  43. 1 optional :extra_headers, OpenAI::Internal::Type::HashOf[String, nil?: true]
  44. # @!attribute extra_body
  45. # Extra data to send with the request. These are deep merged into any data
  46. # generated as part of the normal request.
  47. #
  48. # @return [Object, nil]
  49. 1 optional :extra_body, OpenAI::Internal::Type::HashOf[OpenAI::Internal::Type::Unknown]
  50. # @!attribute max_retries
  51. # Maximum number of retries to attempt after a failed initial request.
  52. #
  53. # @return [Integer, nil]
  54. 1 optional :max_retries, Integer
  55. # @!attribute timeout
  56. # Request timeout in seconds.
  57. #
  58. # @return [Float, nil]
  59. 1 optional :timeout, Float
  60. # @!method initialize(values = {})
  61. # Returns a new instance of RequestOptions.
  62. #
  63. # @param values [Hash{Symbol=>Object}]
  64. 1 define_sorbet_constant!(:OrHash) do
  65. T.type_alias { T.any(OpenAI::RequestOptions, OpenAI::Internal::AnyHash) }
  66. end
  67. end
  68. end

openai-ruby/lib/openai/resources/audio.rb

100.0% lines covered

100.0% branches covered

11 relevant lines. 11 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Audio
  5. # @return [OpenAI::Resources::Audio::Transcriptions]
  6. 1 attr_reader :transcriptions
  7. # @return [OpenAI::Resources::Audio::Translations]
  8. 1 attr_reader :translations
  9. # @return [OpenAI::Resources::Audio::Speech]
  10. 1 attr_reader :speech
  11. # @api private
  12. #
  13. # @param client [OpenAI::Client]
  14. 1 def initialize(client:)
  15. 2 @client = client
  16. 2 @transcriptions = OpenAI::Resources::Audio::Transcriptions.new(client: client)
  17. 2 @translations = OpenAI::Resources::Audio::Translations.new(client: client)
  18. 2 @speech = OpenAI::Resources::Audio::Speech.new(client: client)
  19. end
  20. end
  21. end
  22. end

openai-ruby/lib/openai/resources/audio/speech.rb

77.78% lines covered

100.0% branches covered

9 relevant lines. 7 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Audio
  5. 1 class Speech
  6. # Some parameter documentations has been truncated, see
  7. # {OpenAI::Models::Audio::SpeechCreateParams} for more details.
  8. #
  9. # Generates audio from the input text.
  10. #
  11. # @overload create(input:, model:, voice:, instructions: nil, response_format: nil, speed: nil, stream_format: nil, request_options: {})
  12. #
  13. # @param input [String] The text to generate audio for. The maximum length is 4096 characters.
  14. #
  15. # @param model [String, Symbol, OpenAI::Models::Audio::SpeechModel] One of the available [TTS models](https://platform.openai.com/docs/models#tts):
  16. #
  17. # @param voice [String, Symbol, OpenAI::Models::Audio::SpeechCreateParams::Voice] The voice to use when generating the audio. Supported voices are `alloy`, `ash`,
  18. #
  19. # @param instructions [String] Control the voice of your generated audio with additional instructions. Does not
  20. #
  21. # @param response_format [Symbol, OpenAI::Models::Audio::SpeechCreateParams::ResponseFormat] The format to audio in. Supported formats are `mp3`, `opus`, `aac`, `flac`, `wav
  22. #
  23. # @param speed [Float] The speed of the generated audio. Select a value from `0.25` to `4.0`. `1.0` is
  24. #
  25. # @param stream_format [Symbol, OpenAI::Models::Audio::SpeechCreateParams::StreamFormat] The format to stream the audio in. Supported formats are `sse` and `audio`. `sse
  26. #
  27. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  28. #
  29. # @return [StringIO]
  30. #
  31. # @see OpenAI::Models::Audio::SpeechCreateParams
  32. 1 def create(params)
  33. parsed, options = OpenAI::Audio::SpeechCreateParams.dump_request(params)
  34. @client.request(
  35. method: :post,
  36. path: "audio/speech",
  37. headers: {"accept" => "application/octet-stream"},
  38. body: parsed,
  39. model: StringIO,
  40. options: options
  41. )
  42. end
  43. # @api private
  44. #
  45. # @param client [OpenAI::Client]
  46. 1 def initialize(client:)
  47. 2 @client = client
  48. end
  49. end
  50. end
  51. end
  52. end

openai-ruby/lib/openai/resources/audio/transcriptions.rb

42.11% lines covered

0.0% branches covered

19 relevant lines. 8 lines covered and 11 lines missed.
4 total branches, 0 branches covered and 4 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Audio
  5. 1 class Transcriptions
  6. # See {OpenAI::Resources::Audio::Transcriptions#create_streaming} for streaming
  7. # counterpart.
  8. #
  9. # Some parameter documentations has been truncated, see
  10. # {OpenAI::Models::Audio::TranscriptionCreateParams} for more details.
  11. #
  12. # Transcribes audio into the input language.
  13. #
  14. # @overload create(file:, model:, chunking_strategy: nil, include: nil, language: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {})
  15. #
  16. # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) to transcribe, in one of these formats: fl
  17. #
  18. # @param model [String, Symbol, OpenAI::Models::AudioModel] ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transc
  19. #
  20. # @param chunking_strategy [Symbol, :auto, OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig, nil] Controls how the audio is cut into chunks. When set to `"auto"`, the server firs
  21. #
  22. # @param include [Array<Symbol, OpenAI::Models::Audio::TranscriptionInclude>] Additional information to include in the transcription response.
  23. #
  24. # @param language [String] The language of the input audio. Supplying the input language in [ISO-639-1](htt
  25. #
  26. # @param prompt [String] An optional text to guide the model's style or continue a previous audio segment
  27. #
  28. # @param response_format [Symbol, OpenAI::Models::AudioResponseFormat] The format of the output, in one of these options: `json`, `text`, `srt`, `verbo
  29. #
  30. # @param temperature [Float] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
  31. #
  32. # @param timestamp_granularities [Array<Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity>] The timestamp granularities to populate for this transcription. `response_format
  33. #
  34. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  35. #
  36. # @return [OpenAI::Models::Audio::Transcription, OpenAI::Models::Audio::TranscriptionVerbose]
  37. #
  38. # @see OpenAI::Models::Audio::TranscriptionCreateParams
  39. 1 def create(params)
  40. parsed, options = OpenAI::Audio::TranscriptionCreateParams.dump_request(params)
  41. then: 0 else: 0 if parsed[:stream]
  42. message = "Please use `#create_streaming` for the streaming use case."
  43. raise ArgumentError.new(message)
  44. end
  45. @client.request(
  46. method: :post,
  47. path: "audio/transcriptions",
  48. headers: {"content-type" => "multipart/form-data"},
  49. body: parsed,
  50. model: OpenAI::Models::Audio::TranscriptionCreateResponse,
  51. options: options
  52. )
  53. end
  54. # See {OpenAI::Resources::Audio::Transcriptions#create} for non-streaming
  55. # counterpart.
  56. #
  57. # Some parameter documentations has been truncated, see
  58. # {OpenAI::Models::Audio::TranscriptionCreateParams} for more details.
  59. #
  60. # Transcribes audio into the input language.
  61. #
  62. # @overload create_streaming(file:, model:, chunking_strategy: nil, include: nil, language: nil, prompt: nil, response_format: nil, temperature: nil, timestamp_granularities: nil, request_options: {})
  63. #
  64. # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) to transcribe, in one of these formats: fl
  65. #
  66. # @param model [String, Symbol, OpenAI::Models::AudioModel] ID of the model to use. The options are `gpt-4o-transcribe`, `gpt-4o-mini-transc
  67. #
  68. # @param chunking_strategy [Symbol, :auto, OpenAI::Models::Audio::TranscriptionCreateParams::ChunkingStrategy::VadConfig, nil] Controls how the audio is cut into chunks. When set to `"auto"`, the server firs
  69. #
  70. # @param include [Array<Symbol, OpenAI::Models::Audio::TranscriptionInclude>] Additional information to include in the transcription response.
  71. #
  72. # @param language [String] The language of the input audio. Supplying the input language in [ISO-639-1](htt
  73. #
  74. # @param prompt [String] An optional text to guide the model's style or continue a previous audio segment
  75. #
  76. # @param response_format [Symbol, OpenAI::Models::AudioResponseFormat] The format of the output, in one of these options: `json`, `text`, `srt`, `verbo
  77. #
  78. # @param temperature [Float] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
  79. #
  80. # @param timestamp_granularities [Array<Symbol, OpenAI::Models::Audio::TranscriptionCreateParams::TimestampGranularity>] The timestamp granularities to populate for this transcription. `response_format
  81. #
  82. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  83. #
  84. # @return [OpenAI::Internal::Stream<OpenAI::Models::Audio::TranscriptionTextDeltaEvent, OpenAI::Models::Audio::TranscriptionTextDoneEvent>]
  85. #
  86. # @see OpenAI::Models::Audio::TranscriptionCreateParams
  87. 1 def create_streaming(params)
  88. parsed, options = OpenAI::Audio::TranscriptionCreateParams.dump_request(params)
  89. else: 0 then: 0 unless parsed.fetch(:stream, true)
  90. message = "Please use `#create` for the non-streaming use case."
  91. raise ArgumentError.new(message)
  92. end
  93. parsed.store(:stream, true)
  94. @client.request(
  95. method: :post,
  96. path: "audio/transcriptions",
  97. headers: {"content-type" => "multipart/form-data", "accept" => "text/event-stream"},
  98. body: parsed,
  99. stream: OpenAI::Internal::Stream,
  100. model: OpenAI::Audio::TranscriptionStreamEvent,
  101. options: options
  102. )
  103. end
  104. # @api private
  105. #
  106. # @param client [OpenAI::Client]
  107. 1 def initialize(client:)
  108. 2 @client = client
  109. end
  110. end
  111. end
  112. end
  113. end

openai-ruby/lib/openai/resources/audio/translations.rb

77.78% lines covered

100.0% branches covered

9 relevant lines. 7 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Audio
  5. 1 class Translations
  6. # Some parameter documentations has been truncated, see
  7. # {OpenAI::Models::Audio::TranslationCreateParams} for more details.
  8. #
  9. # Translates audio into English.
  10. #
  11. # @overload create(file:, model:, prompt: nil, response_format: nil, temperature: nil, request_options: {})
  12. #
  13. # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The audio file object (not file name) translate, in one of these formats: flac,
  14. #
  15. # @param model [String, Symbol, OpenAI::Models::AudioModel] ID of the model to use. Only `whisper-1` (which is powered by our open source Wh
  16. #
  17. # @param prompt [String] An optional text to guide the model's style or continue a previous audio segment
  18. #
  19. # @param response_format [Symbol, OpenAI::Models::Audio::TranslationCreateParams::ResponseFormat] The format of the output, in one of these options: `json`, `text`, `srt`, `verbo
  20. #
  21. # @param temperature [Float] The sampling temperature, between 0 and 1. Higher values like 0.8 will make the
  22. #
  23. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  24. #
  25. # @return [OpenAI::Models::Audio::Translation, OpenAI::Models::Audio::TranslationVerbose]
  26. #
  27. # @see OpenAI::Models::Audio::TranslationCreateParams
  28. 1 def create(params)
  29. parsed, options = OpenAI::Audio::TranslationCreateParams.dump_request(params)
  30. @client.request(
  31. method: :post,
  32. path: "audio/translations",
  33. headers: {"content-type" => "multipart/form-data"},
  34. body: parsed,
  35. model: OpenAI::Models::Audio::TranslationCreateResponse,
  36. options: options
  37. )
  38. end
  39. # @api private
  40. #
  41. # @param client [OpenAI::Client]
  42. 1 def initialize(client:)
  43. 2 @client = client
  44. end
  45. end
  46. end
  47. end
  48. end

openai-ruby/lib/openai/resources/batches.rb

60.0% lines covered

100.0% branches covered

15 relevant lines. 9 lines covered and 6 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Batches
  5. # Some parameter documentations has been truncated, see
  6. # {OpenAI::Models::BatchCreateParams} for more details.
  7. #
  8. # Creates and executes a batch from an uploaded file of requests
  9. #
  10. # @overload create(completion_window:, endpoint:, input_file_id:, metadata: nil, request_options: {})
  11. #
  12. # @param completion_window [Symbol, OpenAI::Models::BatchCreateParams::CompletionWindow] The time frame within which the batch should be processed. Currently only `24h`
  13. #
  14. # @param endpoint [Symbol, OpenAI::Models::BatchCreateParams::Endpoint] The endpoint to be used for all requests in the batch. Currently `/v1/responses`
  15. #
  16. # @param input_file_id [String] The ID of an uploaded file that contains requests for the new batch.
  17. #
  18. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  19. #
  20. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  21. #
  22. # @return [OpenAI::Models::Batch]
  23. #
  24. # @see OpenAI::Models::BatchCreateParams
  25. 1 def create(params)
  26. parsed, options = OpenAI::BatchCreateParams.dump_request(params)
  27. @client.request(method: :post, path: "batches", body: parsed, model: OpenAI::Batch, options: options)
  28. end
  29. # Retrieves a batch.
  30. #
  31. # @overload retrieve(batch_id, request_options: {})
  32. #
  33. # @param batch_id [String] The ID of the batch to retrieve.
  34. #
  35. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  36. #
  37. # @return [OpenAI::Models::Batch]
  38. #
  39. # @see OpenAI::Models::BatchRetrieveParams
  40. 1 def retrieve(batch_id, params = {})
  41. @client.request(
  42. method: :get,
  43. path: ["batches/%1$s", batch_id],
  44. model: OpenAI::Batch,
  45. options: params[:request_options]
  46. )
  47. end
  48. # Some parameter documentations has been truncated, see
  49. # {OpenAI::Models::BatchListParams} for more details.
  50. #
  51. # List your organization's batches.
  52. #
  53. # @overload list(after: nil, limit: nil, request_options: {})
  54. #
  55. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  56. #
  57. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  58. #
  59. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  60. #
  61. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Batch>]
  62. #
  63. # @see OpenAI::Models::BatchListParams
  64. 1 def list(params = {})
  65. parsed, options = OpenAI::BatchListParams.dump_request(params)
  66. @client.request(
  67. method: :get,
  68. path: "batches",
  69. query: parsed,
  70. page: OpenAI::Internal::CursorPage,
  71. model: OpenAI::Batch,
  72. options: options
  73. )
  74. end
  75. # Cancels an in-progress batch. The batch will be in status `cancelling` for up to
  76. # 10 minutes, before changing to `cancelled`, where it will have partial results
  77. # (if any) available in the output file.
  78. #
  79. # @overload cancel(batch_id, request_options: {})
  80. #
  81. # @param batch_id [String] The ID of the batch to cancel.
  82. #
  83. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  84. #
  85. # @return [OpenAI::Models::Batch]
  86. #
  87. # @see OpenAI::Models::BatchCancelParams
  88. 1 def cancel(batch_id, params = {})
  89. @client.request(
  90. method: :post,
  91. path: ["batches/%1$s/cancel", batch_id],
  92. model: OpenAI::Batch,
  93. options: params[:request_options]
  94. )
  95. end
  96. # @api private
  97. #
  98. # @param client [OpenAI::Client]
  99. 1 def initialize(client:)
  100. 2 @client = client
  101. end
  102. end
  103. end
  104. end

openai-ruby/lib/openai/resources/beta.rb

100.0% lines covered

100.0% branches covered

9 relevant lines. 9 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Beta
  5. # @return [OpenAI::Resources::Beta::Assistants]
  6. 1 attr_reader :assistants
  7. # @return [OpenAI::Resources::Beta::Threads]
  8. 1 attr_reader :threads
  9. # @api private
  10. #
  11. # @param client [OpenAI::Client]
  12. 1 def initialize(client:)
  13. 2 @client = client
  14. 2 @assistants = OpenAI::Resources::Beta::Assistants.new(client: client)
  15. 2 @threads = OpenAI::Resources::Beta::Threads.new(client: client)
  16. end
  17. end
  18. end
  19. end

openai-ruby/lib/openai/resources/beta/assistants.rb

57.89% lines covered

100.0% branches covered

19 relevant lines. 11 lines covered and 8 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Beta
  5. 1 class Assistants
  6. # Some parameter documentations has been truncated, see
  7. # {OpenAI::Models::Beta::AssistantCreateParams} for more details.
  8. #
  9. # Create an assistant with a model and instructions.
  10. #
  11. # @overload create(model:, description: nil, instructions: nil, metadata: nil, name: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_resources: nil, tools: nil, top_p: nil, request_options: {})
  12. #
  13. # @param model [String, Symbol, OpenAI::Models::ChatModel] ID of the model to use. You can use the [List models](https://platform.openai.co
  14. #
  15. # @param description [String, nil] The description of the assistant. The maximum length is 512 characters.
  16. #
  17. # @param instructions [String, nil] The system instructions that the assistant uses. The maximum length is 256,000 c
  18. #
  19. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  20. #
  21. # @param name [String, nil] The name of the assistant. The maximum length is 256 characters.
  22. #
  23. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] **o-series models only**
  24. #
  25. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  26. #
  27. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  28. #
  29. # @param tool_resources [OpenAI::Models::Beta::AssistantCreateParams::ToolResources, nil] A set of resources that are used by the assistant's tools. The resources are spe
  30. #
  31. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>] A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  32. #
  33. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  34. #
  35. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  36. #
  37. # @return [OpenAI::Models::Beta::Assistant]
  38. #
  39. # @see OpenAI::Models::Beta::AssistantCreateParams
  40. 1 def create(params)
  41. parsed, options = OpenAI::Beta::AssistantCreateParams.dump_request(params)
  42. @client.request(
  43. method: :post,
  44. path: "assistants",
  45. body: parsed,
  46. model: OpenAI::Beta::Assistant,
  47. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  48. )
  49. end
  50. # Retrieves an assistant.
  51. #
  52. # @overload retrieve(assistant_id, request_options: {})
  53. #
  54. # @param assistant_id [String] The ID of the assistant to retrieve.
  55. #
  56. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  57. #
  58. # @return [OpenAI::Models::Beta::Assistant]
  59. #
  60. # @see OpenAI::Models::Beta::AssistantRetrieveParams
  61. 1 def retrieve(assistant_id, params = {})
  62. @client.request(
  63. method: :get,
  64. path: ["assistants/%1$s", assistant_id],
  65. model: OpenAI::Beta::Assistant,
  66. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **params[:request_options].to_h}
  67. )
  68. end
  69. # Some parameter documentations has been truncated, see
  70. # {OpenAI::Models::Beta::AssistantUpdateParams} for more details.
  71. #
  72. # Modifies an assistant.
  73. #
  74. # @overload update(assistant_id, description: nil, instructions: nil, metadata: nil, model: nil, name: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_resources: nil, tools: nil, top_p: nil, request_options: {})
  75. #
  76. # @param assistant_id [String] The ID of the assistant to modify.
  77. #
  78. # @param description [String, nil] The description of the assistant. The maximum length is 512 characters.
  79. #
  80. # @param instructions [String, nil] The system instructions that the assistant uses. The maximum length is 256,000 c
  81. #
  82. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  83. #
  84. # @param model [String, Symbol, OpenAI::Models::Beta::AssistantUpdateParams::Model] ID of the model to use. You can use the [List models](https://platform.openai.co
  85. #
  86. # @param name [String, nil] The name of the assistant. The maximum length is 256 characters.
  87. #
  88. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] **o-series models only**
  89. #
  90. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  91. #
  92. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  93. #
  94. # @param tool_resources [OpenAI::Models::Beta::AssistantUpdateParams::ToolResources, nil] A set of resources that are used by the assistant's tools. The resources are spe
  95. #
  96. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>] A list of tool enabled on the assistant. There can be a maximum of 128 tools per
  97. #
  98. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  99. #
  100. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  101. #
  102. # @return [OpenAI::Models::Beta::Assistant]
  103. #
  104. # @see OpenAI::Models::Beta::AssistantUpdateParams
  105. 1 def update(assistant_id, params = {})
  106. parsed, options = OpenAI::Beta::AssistantUpdateParams.dump_request(params)
  107. @client.request(
  108. method: :post,
  109. path: ["assistants/%1$s", assistant_id],
  110. body: parsed,
  111. model: OpenAI::Beta::Assistant,
  112. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  113. )
  114. end
  115. # Some parameter documentations has been truncated, see
  116. # {OpenAI::Models::Beta::AssistantListParams} for more details.
  117. #
  118. # Returns a list of assistants.
  119. #
  120. # @overload list(after: nil, before: nil, limit: nil, order: nil, request_options: {})
  121. #
  122. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  123. #
  124. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  125. #
  126. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  127. #
  128. # @param order [Symbol, OpenAI::Models::Beta::AssistantListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  129. #
  130. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  131. #
  132. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Beta::Assistant>]
  133. #
  134. # @see OpenAI::Models::Beta::AssistantListParams
  135. 1 def list(params = {})
  136. parsed, options = OpenAI::Beta::AssistantListParams.dump_request(params)
  137. @client.request(
  138. method: :get,
  139. path: "assistants",
  140. query: parsed,
  141. page: OpenAI::Internal::CursorPage,
  142. model: OpenAI::Beta::Assistant,
  143. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  144. )
  145. end
  146. # Delete an assistant.
  147. #
  148. # @overload delete(assistant_id, request_options: {})
  149. #
  150. # @param assistant_id [String] The ID of the assistant to delete.
  151. #
  152. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  153. #
  154. # @return [OpenAI::Models::Beta::AssistantDeleted]
  155. #
  156. # @see OpenAI::Models::Beta::AssistantDeleteParams
  157. 1 def delete(assistant_id, params = {})
  158. @client.request(
  159. method: :delete,
  160. path: ["assistants/%1$s", assistant_id],
  161. model: OpenAI::Beta::AssistantDeleted,
  162. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **params[:request_options].to_h}
  163. )
  164. end
  165. # @api private
  166. #
  167. # @param client [OpenAI::Client]
  168. 1 def initialize(client:)
  169. 2 @client = client
  170. end
  171. end
  172. end
  173. end
  174. end

openai-ruby/lib/openai/resources/beta/threads.rb

48.57% lines covered

0.0% branches covered

35 relevant lines. 17 lines covered and 18 lines missed.
4 total branches, 0 branches covered and 4 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Beta
  5. # @deprecated The Assistants API is deprecated in favor of the Responses API
  6. 1 class Threads
  7. # @return [OpenAI::Resources::Beta::Threads::Runs]
  8. 1 attr_reader :runs
  9. # @return [OpenAI::Resources::Beta::Threads::Messages]
  10. 1 attr_reader :messages
  11. # @deprecated The Assistants API is deprecated in favor of the Responses API
  12. #
  13. # Some parameter documentations has been truncated, see
  14. # {OpenAI::Models::Beta::ThreadCreateParams} for more details.
  15. #
  16. # Create a thread.
  17. #
  18. # @overload create(messages: nil, metadata: nil, tool_resources: nil, request_options: {})
  19. #
  20. # @param messages [Array<OpenAI::Models::Beta::ThreadCreateParams::Message>] A list of [messages](https://platform.openai.com/docs/api-reference/messages) to
  21. #
  22. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  23. #
  24. # @param tool_resources [OpenAI::Models::Beta::ThreadCreateParams::ToolResources, nil] A set of resources that are made available to the assistant's tools in this thre
  25. #
  26. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  27. #
  28. # @return [OpenAI::Models::Beta::Thread]
  29. #
  30. # @see OpenAI::Models::Beta::ThreadCreateParams
  31. 1 def create(params = {})
  32. parsed, options = OpenAI::Beta::ThreadCreateParams.dump_request(params)
  33. @client.request(
  34. method: :post,
  35. path: "threads",
  36. body: parsed,
  37. model: OpenAI::Beta::Thread,
  38. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  39. )
  40. end
  41. # @deprecated The Assistants API is deprecated in favor of the Responses API
  42. #
  43. # Retrieves a thread.
  44. #
  45. # @overload retrieve(thread_id, request_options: {})
  46. #
  47. # @param thread_id [String] The ID of the thread to retrieve.
  48. #
  49. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  50. #
  51. # @return [OpenAI::Models::Beta::Thread]
  52. #
  53. # @see OpenAI::Models::Beta::ThreadRetrieveParams
  54. 1 def retrieve(thread_id, params = {})
  55. @client.request(
  56. method: :get,
  57. path: ["threads/%1$s", thread_id],
  58. model: OpenAI::Beta::Thread,
  59. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **params[:request_options].to_h}
  60. )
  61. end
  62. # @deprecated The Assistants API is deprecated in favor of the Responses API
  63. #
  64. # Some parameter documentations has been truncated, see
  65. # {OpenAI::Models::Beta::ThreadUpdateParams} for more details.
  66. #
  67. # Modifies a thread.
  68. #
  69. # @overload update(thread_id, metadata: nil, tool_resources: nil, request_options: {})
  70. #
  71. # @param thread_id [String] The ID of the thread to modify. Only the `metadata` can be modified.
  72. #
  73. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  74. #
  75. # @param tool_resources [OpenAI::Models::Beta::ThreadUpdateParams::ToolResources, nil] A set of resources that are made available to the assistant's tools in this thre
  76. #
  77. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  78. #
  79. # @return [OpenAI::Models::Beta::Thread]
  80. #
  81. # @see OpenAI::Models::Beta::ThreadUpdateParams
  82. 1 def update(thread_id, params = {})
  83. parsed, options = OpenAI::Beta::ThreadUpdateParams.dump_request(params)
  84. @client.request(
  85. method: :post,
  86. path: ["threads/%1$s", thread_id],
  87. body: parsed,
  88. model: OpenAI::Beta::Thread,
  89. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  90. )
  91. end
  92. # @deprecated The Assistants API is deprecated in favor of the Responses API
  93. #
  94. # Delete a thread.
  95. #
  96. # @overload delete(thread_id, request_options: {})
  97. #
  98. # @param thread_id [String] The ID of the thread to delete.
  99. #
  100. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  101. #
  102. # @return [OpenAI::Models::Beta::ThreadDeleted]
  103. #
  104. # @see OpenAI::Models::Beta::ThreadDeleteParams
  105. 1 def delete(thread_id, params = {})
  106. @client.request(
  107. method: :delete,
  108. path: ["threads/%1$s", thread_id],
  109. model: OpenAI::Beta::ThreadDeleted,
  110. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **params[:request_options].to_h}
  111. )
  112. end
  113. # @deprecated The Assistants API is deprecated in favor of the Responses API
  114. #
  115. # See {OpenAI::Resources::Beta::Threads#stream_raw} for streaming counterpart.
  116. #
  117. # Some parameter documentations has been truncated, see
  118. # {OpenAI::Models::Beta::ThreadCreateAndRunParams} for more details.
  119. #
  120. # Create a thread and run it in one request.
  121. #
  122. # @overload create_and_run(assistant_id:, instructions: nil, max_completion_tokens: nil, max_prompt_tokens: nil, metadata: nil, model: nil, parallel_tool_calls: nil, response_format: nil, temperature: nil, thread: nil, tool_choice: nil, tool_resources: nil, tools: nil, top_p: nil, truncation_strategy: nil, request_options: {})
  123. #
  124. # @param assistant_id [String] The ID of the [assistant](https://platform.openai.com/docs/api-reference/assista
  125. #
  126. # @param instructions [String, nil] Override the default system message of the assistant. This is useful for modifyi
  127. #
  128. # @param max_completion_tokens [Integer, nil] The maximum number of completion tokens that may be used over the course of the
  129. #
  130. # @param max_prompt_tokens [Integer, nil] The maximum number of prompt tokens that may be used over the course of the run.
  131. #
  132. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  133. #
  134. # @param model [String, Symbol, OpenAI::Models::ChatModel, nil] The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
  135. #
  136. # @param parallel_tool_calls [Boolean] Whether to enable [parallel function calling](https://platform.openai.com/docs/g
  137. #
  138. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  139. #
  140. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  141. #
  142. # @param thread [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread] Options to create a new thread. If no thread is provided when running a
  143. #
  144. # @param tool_choice [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil] Controls which (if any) tool is called by the model.
  145. #
  146. # @param tool_resources [OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources, nil] A set of resources that are used by the assistant's tools. The resources are spe
  147. #
  148. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil] Override the tools the assistant can use for this run. This is useful for modify
  149. #
  150. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  151. #
  152. # @param truncation_strategy [OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy, nil] Controls for how a thread will be truncated prior to the run. Use this to contro
  153. #
  154. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  155. #
  156. # @return [OpenAI::Models::Beta::Threads::Run]
  157. #
  158. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams
  159. 1 def create_and_run(params)
  160. parsed, options = OpenAI::Beta::ThreadCreateAndRunParams.dump_request(params)
  161. then: 0 else: 0 if parsed[:stream]
  162. message = "Please use `#stream_raw` for the streaming use case."
  163. raise ArgumentError.new(message)
  164. end
  165. @client.request(
  166. method: :post,
  167. path: "threads/runs",
  168. body: parsed,
  169. model: OpenAI::Beta::Threads::Run,
  170. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  171. )
  172. end
  173. 1 def stream
  174. raise NotImplementedError.new("higher level helpers are coming soon!")
  175. end
  176. # @deprecated The Assistants API is deprecated in favor of the Responses API
  177. #
  178. # See {OpenAI::Resources::Beta::Threads#create_and_run} for non-streaming
  179. # counterpart.
  180. #
  181. # Some parameter documentations has been truncated, see
  182. # {OpenAI::Models::Beta::ThreadCreateAndRunParams} for more details.
  183. #
  184. # Create a thread and run it in one request.
  185. #
  186. # @overload stream_raw(assistant_id:, instructions: nil, max_completion_tokens: nil, max_prompt_tokens: nil, metadata: nil, model: nil, parallel_tool_calls: nil, response_format: nil, temperature: nil, thread: nil, tool_choice: nil, tool_resources: nil, tools: nil, top_p: nil, truncation_strategy: nil, request_options: {})
  187. #
  188. # @param assistant_id [String] The ID of the [assistant](https://platform.openai.com/docs/api-reference/assista
  189. #
  190. # @param instructions [String, nil] Override the default system message of the assistant. This is useful for modifyi
  191. #
  192. # @param max_completion_tokens [Integer, nil] The maximum number of completion tokens that may be used over the course of the
  193. #
  194. # @param max_prompt_tokens [Integer, nil] The maximum number of prompt tokens that may be used over the course of the run.
  195. #
  196. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  197. #
  198. # @param model [String, Symbol, OpenAI::Models::ChatModel, nil] The ID of the [Model](https://platform.openai.com/docs/api-reference/models) to
  199. #
  200. # @param parallel_tool_calls [Boolean] Whether to enable [parallel function calling](https://platform.openai.com/docs/g
  201. #
  202. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Specifies the format that the model must output. Compatible with [GPT-4o](https:
  203. #
  204. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  205. #
  206. # @param thread [OpenAI::Models::Beta::ThreadCreateAndRunParams::Thread] Options to create a new thread. If no thread is provided when running a
  207. #
  208. # @param tool_choice [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil] Controls which (if any) tool is called by the model.
  209. #
  210. # @param tool_resources [OpenAI::Models::Beta::ThreadCreateAndRunParams::ToolResources, nil] A set of resources that are used by the assistant's tools. The resources are spe
  211. #
  212. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil] Override the tools the assistant can use for this run. This is useful for modify
  213. #
  214. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  215. #
  216. # @param truncation_strategy [OpenAI::Models::Beta::ThreadCreateAndRunParams::TruncationStrategy, nil] Controls for how a thread will be truncated prior to the run. Use this to contro
  217. #
  218. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  219. #
  220. # @return [OpenAI::Internal::Stream<OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent>]
  221. #
  222. # @see OpenAI::Models::Beta::ThreadCreateAndRunParams
  223. 1 def stream_raw(params)
  224. parsed, options = OpenAI::Beta::ThreadCreateAndRunParams.dump_request(params)
  225. else: 0 then: 0 unless parsed.fetch(:stream, true)
  226. message = "Please use `#create_and_run` for the non-streaming use case."
  227. raise ArgumentError.new(message)
  228. end
  229. parsed.store(:stream, true)
  230. @client.request(
  231. method: :post,
  232. path: "threads/runs",
  233. headers: {"accept" => "text/event-stream"},
  234. body: parsed,
  235. stream: OpenAI::Internal::Stream,
  236. model: OpenAI::Beta::AssistantStreamEvent,
  237. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  238. )
  239. end
  240. # @api private
  241. #
  242. # @param client [OpenAI::Client]
  243. 1 def initialize(client:)
  244. 2 @client = client
  245. 2 @runs = OpenAI::Resources::Beta::Threads::Runs.new(client: client)
  246. 2 @messages = OpenAI::Resources::Beta::Threads::Messages.new(client: client)
  247. end
  248. end
  249. end
  250. end
  251. end

openai-ruby/lib/openai/resources/beta/threads/messages.rb

42.86% lines covered

100.0% branches covered

28 relevant lines. 12 lines covered and 16 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Beta
  5. 1 class Threads
  6. # @deprecated The Assistants API is deprecated in favor of the Responses API
  7. 1 class Messages
  8. # @deprecated The Assistants API is deprecated in favor of the Responses API
  9. #
  10. # Some parameter documentations has been truncated, see
  11. # {OpenAI::Models::Beta::Threads::MessageCreateParams} for more details.
  12. #
  13. # Create a message.
  14. #
  15. # @overload create(thread_id, content:, role:, attachments: nil, metadata: nil, request_options: {})
  16. #
  17. # @param thread_id [String] The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) t
  18. #
  19. # @param content [String, Array<OpenAI::Models::Beta::Threads::ImageFileContentBlock, OpenAI::Models::Beta::Threads::ImageURLContentBlock, OpenAI::Models::Beta::Threads::TextContentBlockParam>] The text contents of the message.
  20. #
  21. # @param role [Symbol, OpenAI::Models::Beta::Threads::MessageCreateParams::Role] The role of the entity that is creating the message. Allowed values include:
  22. #
  23. # @param attachments [Array<OpenAI::Models::Beta::Threads::MessageCreateParams::Attachment>, nil] A list of files attached to the message, and the tools they should be added to.
  24. #
  25. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  26. #
  27. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  28. #
  29. # @return [OpenAI::Models::Beta::Threads::Message]
  30. #
  31. # @see OpenAI::Models::Beta::Threads::MessageCreateParams
  32. 1 def create(thread_id, params)
  33. parsed, options = OpenAI::Beta::Threads::MessageCreateParams.dump_request(params)
  34. @client.request(
  35. method: :post,
  36. path: ["threads/%1$s/messages", thread_id],
  37. body: parsed,
  38. model: OpenAI::Beta::Threads::Message,
  39. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  40. )
  41. end
  42. # @deprecated The Assistants API is deprecated in favor of the Responses API
  43. #
  44. # Some parameter documentations has been truncated, see
  45. # {OpenAI::Models::Beta::Threads::MessageRetrieveParams} for more details.
  46. #
  47. # Retrieve a message.
  48. #
  49. # @overload retrieve(message_id, thread_id:, request_options: {})
  50. #
  51. # @param message_id [String] The ID of the message to retrieve.
  52. #
  53. # @param thread_id [String] The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) t
  54. #
  55. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  56. #
  57. # @return [OpenAI::Models::Beta::Threads::Message]
  58. #
  59. # @see OpenAI::Models::Beta::Threads::MessageRetrieveParams
  60. 1 def retrieve(message_id, params)
  61. parsed, options = OpenAI::Beta::Threads::MessageRetrieveParams.dump_request(params)
  62. thread_id =
  63. parsed.delete(:thread_id) do
  64. raise ArgumentError.new("missing required path argument #{_1}")
  65. end
  66. @client.request(
  67. method: :get,
  68. path: ["threads/%1$s/messages/%2$s", thread_id, message_id],
  69. model: OpenAI::Beta::Threads::Message,
  70. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  71. )
  72. end
  73. # @deprecated The Assistants API is deprecated in favor of the Responses API
  74. #
  75. # Some parameter documentations has been truncated, see
  76. # {OpenAI::Models::Beta::Threads::MessageUpdateParams} for more details.
  77. #
  78. # Modifies a message.
  79. #
  80. # @overload update(message_id, thread_id:, metadata: nil, request_options: {})
  81. #
  82. # @param message_id [String] Path param: The ID of the message to modify.
  83. #
  84. # @param thread_id [String] Path param: The ID of the thread to which this message belongs.
  85. #
  86. # @param metadata [Hash{Symbol=>String}, nil] Body param: Set of 16 key-value pairs that can be attached to an object. This ca
  87. #
  88. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  89. #
  90. # @return [OpenAI::Models::Beta::Threads::Message]
  91. #
  92. # @see OpenAI::Models::Beta::Threads::MessageUpdateParams
  93. 1 def update(message_id, params)
  94. parsed, options = OpenAI::Beta::Threads::MessageUpdateParams.dump_request(params)
  95. thread_id =
  96. parsed.delete(:thread_id) do
  97. raise ArgumentError.new("missing required path argument #{_1}")
  98. end
  99. @client.request(
  100. method: :post,
  101. path: ["threads/%1$s/messages/%2$s", thread_id, message_id],
  102. body: parsed,
  103. model: OpenAI::Beta::Threads::Message,
  104. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  105. )
  106. end
  107. # @deprecated The Assistants API is deprecated in favor of the Responses API
  108. #
  109. # Some parameter documentations has been truncated, see
  110. # {OpenAI::Models::Beta::Threads::MessageListParams} for more details.
  111. #
  112. # Returns a list of messages for a given thread.
  113. #
  114. # @overload list(thread_id, after: nil, before: nil, limit: nil, order: nil, run_id: nil, request_options: {})
  115. #
  116. # @param thread_id [String] The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) t
  117. #
  118. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  119. #
  120. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  121. #
  122. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  123. #
  124. # @param order [Symbol, OpenAI::Models::Beta::Threads::MessageListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  125. #
  126. # @param run_id [String] Filter messages by the run ID that generated them.
  127. #
  128. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  129. #
  130. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Beta::Threads::Message>]
  131. #
  132. # @see OpenAI::Models::Beta::Threads::MessageListParams
  133. 1 def list(thread_id, params = {})
  134. parsed, options = OpenAI::Beta::Threads::MessageListParams.dump_request(params)
  135. @client.request(
  136. method: :get,
  137. path: ["threads/%1$s/messages", thread_id],
  138. query: parsed,
  139. page: OpenAI::Internal::CursorPage,
  140. model: OpenAI::Beta::Threads::Message,
  141. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  142. )
  143. end
  144. # @deprecated The Assistants API is deprecated in favor of the Responses API
  145. #
  146. # Deletes a message.
  147. #
  148. # @overload delete(message_id, thread_id:, request_options: {})
  149. #
  150. # @param message_id [String] The ID of the message to delete.
  151. #
  152. # @param thread_id [String] The ID of the thread to which this message belongs.
  153. #
  154. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  155. #
  156. # @return [OpenAI::Models::Beta::Threads::MessageDeleted]
  157. #
  158. # @see OpenAI::Models::Beta::Threads::MessageDeleteParams
  159. 1 def delete(message_id, params)
  160. parsed, options = OpenAI::Beta::Threads::MessageDeleteParams.dump_request(params)
  161. thread_id =
  162. parsed.delete(:thread_id) do
  163. raise ArgumentError.new("missing required path argument #{_1}")
  164. end
  165. @client.request(
  166. method: :delete,
  167. path: ["threads/%1$s/messages/%2$s", thread_id, message_id],
  168. model: OpenAI::Beta::Threads::MessageDeleted,
  169. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  170. )
  171. end
  172. # @api private
  173. #
  174. # @param client [OpenAI::Client]
  175. 1 def initialize(client:)
  176. 2 @client = client
  177. end
  178. end
  179. end
  180. end
  181. end
  182. end

openai-ruby/lib/openai/resources/beta/threads/runs.rb

28.81% lines covered

0.0% branches covered

59 relevant lines. 17 lines covered and 42 lines missed.
8 total branches, 0 branches covered and 8 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Beta
  5. 1 class Threads
  6. # @deprecated The Assistants API is deprecated in favor of the Responses API
  7. 1 class Runs
  8. # @return [OpenAI::Resources::Beta::Threads::Runs::Steps]
  9. 1 attr_reader :steps
  10. # @deprecated The Assistants API is deprecated in favor of the Responses API
  11. #
  12. # See {OpenAI::Resources::Beta::Threads::Runs#create_stream_raw} for streaming
  13. # counterpart.
  14. #
  15. # Some parameter documentations has been truncated, see
  16. # {OpenAI::Models::Beta::Threads::RunCreateParams} for more details.
  17. #
  18. # Create a run.
  19. #
  20. # @overload create(thread_id, assistant_id:, include: nil, additional_instructions: nil, additional_messages: nil, instructions: nil, max_completion_tokens: nil, max_prompt_tokens: nil, metadata: nil, model: nil, parallel_tool_calls: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_choice: nil, tools: nil, top_p: nil, truncation_strategy: nil, request_options: {})
  21. #
  22. # @param thread_id [String] Path param: The ID of the thread to run.
  23. #
  24. # @param assistant_id [String] Body param: The ID of the [assistant](https://platform.openai.com/docs/api-refer
  25. #
  26. # @param include [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>] Query param: A list of additional fields to include in the response. Currently t
  27. #
  28. # @param additional_instructions [String, nil] Body param: Appends additional instructions at the end of the instructions for t
  29. #
  30. # @param additional_messages [Array<OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage>, nil] Body param: Adds additional messages to the thread before creating the run.
  31. #
  32. # @param instructions [String, nil] Body param: Overrides the [instructions](https://platform.openai.com/docs/api-re
  33. #
  34. # @param max_completion_tokens [Integer, nil] Body param: The maximum number of completion tokens that may be used over the co
  35. #
  36. # @param max_prompt_tokens [Integer, nil] Body param: The maximum number of prompt tokens that may be used over the course
  37. #
  38. # @param metadata [Hash{Symbol=>String}, nil] Body param: Set of 16 key-value pairs that can be attached to an object. This ca
  39. #
  40. # @param model [String, Symbol, OpenAI::Models::ChatModel, nil] Body param: The ID of the [Model](https://platform.openai.com/docs/api-reference
  41. #
  42. # @param parallel_tool_calls [Boolean] Body param: Whether to enable [parallel function calling](https://platform.opena
  43. #
  44. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] Body param: **o-series models only**
  45. #
  46. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Body param: Specifies the format that the model must output. Compatible with [GP
  47. #
  48. # @param temperature [Float, nil] Body param: What sampling temperature to use, between 0 and 2. Higher values lik
  49. #
  50. # @param tool_choice [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil] Body param: Controls which (if any) tool is called by the model.
  51. #
  52. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil] Body param: Override the tools the assistant can use for this run. This is usefu
  53. #
  54. # @param top_p [Float, nil] Body param: An alternative to sampling with temperature, called nucleus sampling
  55. #
  56. # @param truncation_strategy [OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy, nil] Body param: Controls for how a thread will be truncated prior to the run. Use th
  57. #
  58. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  59. #
  60. # @return [OpenAI::Models::Beta::Threads::Run]
  61. #
  62. # @see OpenAI::Models::Beta::Threads::RunCreateParams
  63. 1 def create(thread_id, params)
  64. parsed, options = OpenAI::Beta::Threads::RunCreateParams.dump_request(params)
  65. then: 0 else: 0 if parsed[:stream]
  66. message = "Please use `#create_stream_raw` for the streaming use case."
  67. raise ArgumentError.new(message)
  68. end
  69. query_params = [:include]
  70. @client.request(
  71. method: :post,
  72. path: ["threads/%1$s/runs", thread_id],
  73. query: parsed.slice(*query_params),
  74. body: parsed.except(*query_params),
  75. model: OpenAI::Beta::Threads::Run,
  76. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  77. )
  78. end
  79. # @deprecated The Assistants API is deprecated in favor of the Responses API
  80. #
  81. # See {OpenAI::Resources::Beta::Threads::Runs#create} for non-streaming
  82. # counterpart.
  83. #
  84. # Some parameter documentations has been truncated, see
  85. # {OpenAI::Models::Beta::Threads::RunCreateParams} for more details.
  86. #
  87. # Create a run.
  88. #
  89. # @overload create_stream_raw(thread_id, assistant_id:, include: nil, additional_instructions: nil, additional_messages: nil, instructions: nil, max_completion_tokens: nil, max_prompt_tokens: nil, metadata: nil, model: nil, parallel_tool_calls: nil, reasoning_effort: nil, response_format: nil, temperature: nil, tool_choice: nil, tools: nil, top_p: nil, truncation_strategy: nil, request_options: {})
  90. #
  91. # @param thread_id [String] Path param: The ID of the thread to run.
  92. #
  93. # @param assistant_id [String] Body param: The ID of the [assistant](https://platform.openai.com/docs/api-refer
  94. #
  95. # @param include [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>] Query param: A list of additional fields to include in the response. Currently t
  96. #
  97. # @param additional_instructions [String, nil] Body param: Appends additional instructions at the end of the instructions for t
  98. #
  99. # @param additional_messages [Array<OpenAI::Models::Beta::Threads::RunCreateParams::AdditionalMessage>, nil] Body param: Adds additional messages to the thread before creating the run.
  100. #
  101. # @param instructions [String, nil] Body param: Overrides the [instructions](https://platform.openai.com/docs/api-re
  102. #
  103. # @param max_completion_tokens [Integer, nil] Body param: The maximum number of completion tokens that may be used over the co
  104. #
  105. # @param max_prompt_tokens [Integer, nil] Body param: The maximum number of prompt tokens that may be used over the course
  106. #
  107. # @param metadata [Hash{Symbol=>String}, nil] Body param: Set of 16 key-value pairs that can be attached to an object. This ca
  108. #
  109. # @param model [String, Symbol, OpenAI::Models::ChatModel, nil] Body param: The ID of the [Model](https://platform.openai.com/docs/api-reference
  110. #
  111. # @param parallel_tool_calls [Boolean] Body param: Whether to enable [parallel function calling](https://platform.opena
  112. #
  113. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] Body param: **o-series models only**
  114. #
  115. # @param response_format [Symbol, :auto, OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONObject, OpenAI::Models::ResponseFormatJSONSchema, nil] Body param: Specifies the format that the model must output. Compatible with [GP
  116. #
  117. # @param temperature [Float, nil] Body param: What sampling temperature to use, between 0 and 2. Higher values lik
  118. #
  119. # @param tool_choice [Symbol, OpenAI::Models::Beta::AssistantToolChoiceOption::Auto, OpenAI::Models::Beta::AssistantToolChoice, nil] Body param: Controls which (if any) tool is called by the model.
  120. #
  121. # @param tools [Array<OpenAI::Models::Beta::CodeInterpreterTool, OpenAI::Models::Beta::FileSearchTool, OpenAI::Models::Beta::FunctionTool>, nil] Body param: Override the tools the assistant can use for this run. This is usefu
  122. #
  123. # @param top_p [Float, nil] Body param: An alternative to sampling with temperature, called nucleus sampling
  124. #
  125. # @param truncation_strategy [OpenAI::Models::Beta::Threads::RunCreateParams::TruncationStrategy, nil] Body param: Controls for how a thread will be truncated prior to the run. Use th
  126. #
  127. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  128. #
  129. # @return [OpenAI::Internal::Stream<OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent>]
  130. #
  131. # @see OpenAI::Models::Beta::Threads::RunCreateParams
  132. 1 def create_stream_raw(thread_id, params)
  133. parsed, options = OpenAI::Beta::Threads::RunCreateParams.dump_request(params)
  134. else: 0 then: 0 unless parsed.fetch(:stream, true)
  135. message = "Please use `#create` for the non-streaming use case."
  136. raise ArgumentError.new(message)
  137. end
  138. parsed.store(:stream, true)
  139. query_params = [:include]
  140. @client.request(
  141. method: :post,
  142. path: ["threads/%1$s/runs", thread_id],
  143. query: parsed.slice(*query_params),
  144. headers: {"accept" => "text/event-stream"},
  145. body: parsed.except(*query_params),
  146. stream: OpenAI::Internal::Stream,
  147. model: OpenAI::Beta::AssistantStreamEvent,
  148. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  149. )
  150. end
  151. # @deprecated The Assistants API is deprecated in favor of the Responses API
  152. #
  153. # Some parameter documentations has been truncated, see
  154. # {OpenAI::Models::Beta::Threads::RunRetrieveParams} for more details.
  155. #
  156. # Retrieves a run.
  157. #
  158. # @overload retrieve(run_id, thread_id:, request_options: {})
  159. #
  160. # @param run_id [String] The ID of the run to retrieve.
  161. #
  162. # @param thread_id [String] The ID of the [thread](https://platform.openai.com/docs/api-reference/threads) t
  163. #
  164. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  165. #
  166. # @return [OpenAI::Models::Beta::Threads::Run]
  167. #
  168. # @see OpenAI::Models::Beta::Threads::RunRetrieveParams
  169. 1 def retrieve(run_id, params)
  170. parsed, options = OpenAI::Beta::Threads::RunRetrieveParams.dump_request(params)
  171. thread_id =
  172. parsed.delete(:thread_id) do
  173. raise ArgumentError.new("missing required path argument #{_1}")
  174. end
  175. @client.request(
  176. method: :get,
  177. path: ["threads/%1$s/runs/%2$s", thread_id, run_id],
  178. model: OpenAI::Beta::Threads::Run,
  179. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  180. )
  181. end
  182. # @deprecated The Assistants API is deprecated in favor of the Responses API
  183. #
  184. # Some parameter documentations has been truncated, see
  185. # {OpenAI::Models::Beta::Threads::RunUpdateParams} for more details.
  186. #
  187. # Modifies a run.
  188. #
  189. # @overload update(run_id, thread_id:, metadata: nil, request_options: {})
  190. #
  191. # @param run_id [String] Path param: The ID of the run to modify.
  192. #
  193. # @param thread_id [String] Path param: The ID of the [thread](https://platform.openai.com/docs/api-referenc
  194. #
  195. # @param metadata [Hash{Symbol=>String}, nil] Body param: Set of 16 key-value pairs that can be attached to an object. This ca
  196. #
  197. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  198. #
  199. # @return [OpenAI::Models::Beta::Threads::Run]
  200. #
  201. # @see OpenAI::Models::Beta::Threads::RunUpdateParams
  202. 1 def update(run_id, params)
  203. parsed, options = OpenAI::Beta::Threads::RunUpdateParams.dump_request(params)
  204. thread_id =
  205. parsed.delete(:thread_id) do
  206. raise ArgumentError.new("missing required path argument #{_1}")
  207. end
  208. @client.request(
  209. method: :post,
  210. path: ["threads/%1$s/runs/%2$s", thread_id, run_id],
  211. body: parsed,
  212. model: OpenAI::Beta::Threads::Run,
  213. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  214. )
  215. end
  216. # @deprecated The Assistants API is deprecated in favor of the Responses API
  217. #
  218. # Some parameter documentations has been truncated, see
  219. # {OpenAI::Models::Beta::Threads::RunListParams} for more details.
  220. #
  221. # Returns a list of runs belonging to a thread.
  222. #
  223. # @overload list(thread_id, after: nil, before: nil, limit: nil, order: nil, request_options: {})
  224. #
  225. # @param thread_id [String] The ID of the thread the run belongs to.
  226. #
  227. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  228. #
  229. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  230. #
  231. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  232. #
  233. # @param order [Symbol, OpenAI::Models::Beta::Threads::RunListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  234. #
  235. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  236. #
  237. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Beta::Threads::Run>]
  238. #
  239. # @see OpenAI::Models::Beta::Threads::RunListParams
  240. 1 def list(thread_id, params = {})
  241. parsed, options = OpenAI::Beta::Threads::RunListParams.dump_request(params)
  242. @client.request(
  243. method: :get,
  244. path: ["threads/%1$s/runs", thread_id],
  245. query: parsed,
  246. page: OpenAI::Internal::CursorPage,
  247. model: OpenAI::Beta::Threads::Run,
  248. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  249. )
  250. end
  251. # @deprecated The Assistants API is deprecated in favor of the Responses API
  252. #
  253. # Cancels a run that is `in_progress`.
  254. #
  255. # @overload cancel(run_id, thread_id:, request_options: {})
  256. #
  257. # @param run_id [String] The ID of the run to cancel.
  258. #
  259. # @param thread_id [String] The ID of the thread to which this run belongs.
  260. #
  261. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  262. #
  263. # @return [OpenAI::Models::Beta::Threads::Run]
  264. #
  265. # @see OpenAI::Models::Beta::Threads::RunCancelParams
  266. 1 def cancel(run_id, params)
  267. parsed, options = OpenAI::Beta::Threads::RunCancelParams.dump_request(params)
  268. thread_id =
  269. parsed.delete(:thread_id) do
  270. raise ArgumentError.new("missing required path argument #{_1}")
  271. end
  272. @client.request(
  273. method: :post,
  274. path: ["threads/%1$s/runs/%2$s/cancel", thread_id, run_id],
  275. model: OpenAI::Beta::Threads::Run,
  276. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  277. )
  278. end
  279. # @deprecated The Assistants API is deprecated in favor of the Responses API
  280. #
  281. # See {OpenAI::Resources::Beta::Threads::Runs#submit_tool_outputs_stream_raw} for
  282. # streaming counterpart.
  283. #
  284. # Some parameter documentations has been truncated, see
  285. # {OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams} for more details.
  286. #
  287. # When a run has the `status: "requires_action"` and `required_action.type` is
  288. # `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
  289. # tool calls once they're all completed. All outputs must be submitted in a single
  290. # request.
  291. #
  292. # @overload submit_tool_outputs(run_id, thread_id:, tool_outputs:, request_options: {})
  293. #
  294. # @param run_id [String] Path param: The ID of the run that requires the tool output submission.
  295. #
  296. # @param thread_id [String] Path param: The ID of the [thread](https://platform.openai.com/docs/api-referenc
  297. #
  298. # @param tool_outputs [Array<OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput>] Body param: A list of tools for which the outputs are being submitted.
  299. #
  300. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  301. #
  302. # @return [OpenAI::Models::Beta::Threads::Run]
  303. #
  304. # @see OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams
  305. 1 def submit_tool_outputs(run_id, params)
  306. parsed, options = OpenAI::Beta::Threads::RunSubmitToolOutputsParams.dump_request(params)
  307. then: 0 else: 0 if parsed[:stream]
  308. message = "Please use `#submit_tool_outputs_stream_raw` for the streaming use case."
  309. raise ArgumentError.new(message)
  310. end
  311. thread_id =
  312. parsed.delete(:thread_id) do
  313. raise ArgumentError.new("missing required path argument #{_1}")
  314. end
  315. @client.request(
  316. method: :post,
  317. path: ["threads/%1$s/runs/%2$s/submit_tool_outputs", thread_id, run_id],
  318. body: parsed,
  319. model: OpenAI::Beta::Threads::Run,
  320. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  321. )
  322. end
  323. # @deprecated The Assistants API is deprecated in favor of the Responses API
  324. #
  325. # See {OpenAI::Resources::Beta::Threads::Runs#submit_tool_outputs} for
  326. # non-streaming counterpart.
  327. #
  328. # Some parameter documentations has been truncated, see
  329. # {OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams} for more details.
  330. #
  331. # When a run has the `status: "requires_action"` and `required_action.type` is
  332. # `submit_tool_outputs`, this endpoint can be used to submit the outputs from the
  333. # tool calls once they're all completed. All outputs must be submitted in a single
  334. # request.
  335. #
  336. # @overload submit_tool_outputs_stream_raw(run_id, thread_id:, tool_outputs:, request_options: {})
  337. #
  338. # @param run_id [String] Path param: The ID of the run that requires the tool output submission.
  339. #
  340. # @param thread_id [String] Path param: The ID of the [thread](https://platform.openai.com/docs/api-referenc
  341. #
  342. # @param tool_outputs [Array<OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams::ToolOutput>] Body param: A list of tools for which the outputs are being submitted.
  343. #
  344. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  345. #
  346. # @return [OpenAI::Internal::Stream<OpenAI::Models::Beta::AssistantStreamEvent::ThreadCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunQueued, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunRequiresAction, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelling, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepFailed, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepCancelled, OpenAI::Models::Beta::AssistantStreamEvent::ThreadRunStepExpired, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCreated, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageInProgress, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageDelta, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageCompleted, OpenAI::Models::Beta::AssistantStreamEvent::ThreadMessageIncomplete, OpenAI::Models::Beta::AssistantStreamEvent::ErrorEvent>]
  347. #
  348. # @see OpenAI::Models::Beta::Threads::RunSubmitToolOutputsParams
  349. 1 def submit_tool_outputs_stream_raw(run_id, params)
  350. parsed, options = OpenAI::Beta::Threads::RunSubmitToolOutputsParams.dump_request(params)
  351. else: 0 then: 0 unless parsed.fetch(:stream, true)
  352. message = "Please use `#submit_tool_outputs` for the non-streaming use case."
  353. raise ArgumentError.new(message)
  354. end
  355. parsed.store(:stream, true)
  356. thread_id =
  357. parsed.delete(:thread_id) do
  358. raise ArgumentError.new("missing required path argument #{_1}")
  359. end
  360. @client.request(
  361. method: :post,
  362. path: ["threads/%1$s/runs/%2$s/submit_tool_outputs", thread_id, run_id],
  363. headers: {"accept" => "text/event-stream"},
  364. body: parsed,
  365. stream: OpenAI::Internal::Stream,
  366. model: OpenAI::Beta::AssistantStreamEvent,
  367. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  368. )
  369. end
  370. # @api private
  371. #
  372. # @param client [OpenAI::Client]
  373. 1 def initialize(client:)
  374. 2 @client = client
  375. 2 @steps = OpenAI::Resources::Beta::Threads::Runs::Steps.new(client: client)
  376. end
  377. end
  378. end
  379. end
  380. end
  381. end

openai-ruby/lib/openai/resources/beta/threads/runs/steps.rb

50.0% lines covered

100.0% branches covered

20 relevant lines. 10 lines covered and 10 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Beta
  5. 1 class Threads
  6. 1 class Runs
  7. # @deprecated The Assistants API is deprecated in favor of the Responses API
  8. 1 class Steps
  9. # @deprecated The Assistants API is deprecated in favor of the Responses API
  10. #
  11. # Some parameter documentations has been truncated, see
  12. # {OpenAI::Models::Beta::Threads::Runs::StepRetrieveParams} for more details.
  13. #
  14. # Retrieves a run step.
  15. #
  16. # @overload retrieve(step_id, thread_id:, run_id:, include: nil, request_options: {})
  17. #
  18. # @param step_id [String] Path param: The ID of the run step to retrieve.
  19. #
  20. # @param thread_id [String] Path param: The ID of the thread to which the run and run step belongs.
  21. #
  22. # @param run_id [String] Path param: The ID of the run to which the run step belongs.
  23. #
  24. # @param include [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>] Query param: A list of additional fields to include in the response. Currently t
  25. #
  26. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  27. #
  28. # @return [OpenAI::Models::Beta::Threads::Runs::RunStep]
  29. #
  30. # @see OpenAI::Models::Beta::Threads::Runs::StepRetrieveParams
  31. 1 def retrieve(step_id, params)
  32. parsed, options = OpenAI::Beta::Threads::Runs::StepRetrieveParams.dump_request(params)
  33. thread_id =
  34. parsed.delete(:thread_id) do
  35. raise ArgumentError.new("missing required path argument #{_1}")
  36. end
  37. run_id =
  38. parsed.delete(:run_id) do
  39. raise ArgumentError.new("missing required path argument #{_1}")
  40. end
  41. @client.request(
  42. method: :get,
  43. path: ["threads/%1$s/runs/%2$s/steps/%3$s", thread_id, run_id, step_id],
  44. query: parsed,
  45. model: OpenAI::Beta::Threads::Runs::RunStep,
  46. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  47. )
  48. end
  49. # @deprecated The Assistants API is deprecated in favor of the Responses API
  50. #
  51. # Some parameter documentations has been truncated, see
  52. # {OpenAI::Models::Beta::Threads::Runs::StepListParams} for more details.
  53. #
  54. # Returns a list of run steps belonging to a run.
  55. #
  56. # @overload list(run_id, thread_id:, after: nil, before: nil, include: nil, limit: nil, order: nil, request_options: {})
  57. #
  58. # @param run_id [String] Path param: The ID of the run the run steps belong to.
  59. #
  60. # @param thread_id [String] Path param: The ID of the thread the run and run steps belong to.
  61. #
  62. # @param after [String] Query param: A cursor for use in pagination. `after` is an object ID that define
  63. #
  64. # @param before [String] Query param: A cursor for use in pagination. `before` is an object ID that defin
  65. #
  66. # @param include [Array<Symbol, OpenAI::Models::Beta::Threads::Runs::RunStepInclude>] Query param: A list of additional fields to include in the response. Currently t
  67. #
  68. # @param limit [Integer] Query param: A limit on the number of objects to be returned. Limit can range be
  69. #
  70. # @param order [Symbol, OpenAI::Models::Beta::Threads::Runs::StepListParams::Order] Query param: Sort order by the `created_at` timestamp of the objects. `asc` for
  71. #
  72. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  73. #
  74. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Beta::Threads::Runs::RunStep>]
  75. #
  76. # @see OpenAI::Models::Beta::Threads::Runs::StepListParams
  77. 1 def list(run_id, params)
  78. parsed, options = OpenAI::Beta::Threads::Runs::StepListParams.dump_request(params)
  79. thread_id =
  80. parsed.delete(:thread_id) do
  81. raise ArgumentError.new("missing required path argument #{_1}")
  82. end
  83. @client.request(
  84. method: :get,
  85. path: ["threads/%1$s/runs/%2$s/steps", thread_id, run_id],
  86. query: parsed,
  87. page: OpenAI::Internal::CursorPage,
  88. model: OpenAI::Beta::Threads::Runs::RunStep,
  89. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  90. )
  91. end
  92. # @api private
  93. #
  94. # @param client [OpenAI::Client]
  95. 1 def initialize(client:)
  96. 2 @client = client
  97. end
  98. end
  99. end
  100. end
  101. end
  102. end
  103. end

openai-ruby/lib/openai/resources/chat.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Chat
  5. # @return [OpenAI::Resources::Chat::Completions]
  6. 1 attr_reader :completions
  7. # @api private
  8. #
  9. # @param client [OpenAI::Client]
  10. 1 def initialize(client:)
  11. 2 @client = client
  12. 2 @completions = OpenAI::Resources::Chat::Completions.new(client: client)
  13. end
  14. end
  15. end
  16. end

openai-ruby/lib/openai/resources/chat/completions.rb

22.06% lines covered

0.0% branches covered

68 relevant lines. 15 lines covered and 53 lines missed.
22 total branches, 0 branches covered and 22 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Chat
  5. 1 class Completions
  6. # @return [OpenAI::Resources::Chat::Completions::Messages]
  7. 1 attr_reader :messages
  8. # See {OpenAI::Resources::Chat::Completions#stream_raw} for streaming counterpart.
  9. #
  10. # Some parameter documentations has been truncated, see
  11. # {OpenAI::Models::Chat::CompletionCreateParams} for more details.
  12. #
  13. # **Starting a new project?** We recommend trying
  14. # [Responses](https://platform.openai.com/docs/api-reference/responses) to take
  15. # advantage of the latest OpenAI platform features. Compare
  16. # [Chat Completions with Responses](https://platform.openai.com/docs/guides/responses-vs-chat-completions?api-mode=responses).
  17. #
  18. # ---
  19. #
  20. # Creates a model response for the given chat conversation. Learn more in the
  21. # [text generation](https://platform.openai.com/docs/guides/text-generation),
  22. # [vision](https://platform.openai.com/docs/guides/vision), and
  23. # [audio](https://platform.openai.com/docs/guides/audio) guides.
  24. #
  25. # Parameter support can differ depending on the model used to generate the
  26. # response, particularly for newer reasoning models. Parameters that are only
  27. # supported for reasoning models are noted below. For the current state of
  28. # unsupported parameters in reasoning models,
  29. # [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning).
  30. #
  31. # @overload create(messages:, model:, audio: nil, frequency_penalty: nil, function_call: nil, functions: nil, logit_bias: nil, logprobs: nil, max_completion_tokens: nil, max_tokens: nil, metadata: nil, modalities: nil, n: nil, parallel_tool_calls: nil, prediction: nil, presence_penalty: nil, prompt_cache_key: nil, reasoning_effort: nil, response_format: nil, safety_identifier: nil, seed: nil, service_tier: nil, stop: nil, store: nil, stream_options: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, user: nil, web_search_options: nil, request_options: {})
  32. #
  33. # @param messages [Array<OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam>] A list of messages comprising the conversation so far. Depending on the
  34. #
  35. # @param model [String, Symbol, OpenAI::Models::ChatModel] Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
  36. #
  37. # @param audio [OpenAI::Models::Chat::ChatCompletionAudioParam, nil] Parameters for audio output. Required when audio output is requested with
  38. #
  39. # @param frequency_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on
  40. #
  41. # @param function_call [Symbol, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode, OpenAI::Models::Chat::ChatCompletionFunctionCallOption] Deprecated in favor of `tool_choice`.
  42. #
  43. # @param functions [Array<OpenAI::Models::Chat::CompletionCreateParams::Function>] Deprecated in favor of `tools`.
  44. #
  45. # @param logit_bias [Hash{Symbol=>Integer}, nil] Modify the likelihood of specified tokens appearing in the completion.
  46. #
  47. # @param logprobs [Boolean, nil] Whether to return log probabilities of the output tokens or not. If true,
  48. #
  49. # @param max_completion_tokens [Integer, nil] An upper bound for the number of tokens that can be generated for a completion,
  50. #
  51. # @param max_tokens [Integer, nil] The maximum number of [tokens](/tokenizer) that can be generated in the
  52. #
  53. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  54. #
  55. # @param modalities [Array<Symbol, OpenAI::Models::Chat::CompletionCreateParams::Modality>, nil] Output types that you would like the model to generate.
  56. #
  57. # @param n [Integer, nil] How many chat completion choices to generate for each input message. Note that y
  58. #
  59. # @param parallel_tool_calls [Boolean] Whether to enable [parallel function calling](https://platform.openai.com/docs/g
  60. #
  61. # @param prediction [OpenAI::Models::Chat::ChatCompletionPredictionContent, nil] Static predicted output content, such as the content of a text file that is
  62. #
  63. # @param presence_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on
  64. #
  65. # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi
  66. #
  67. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] **o-series models only**
  68. #
  69. # @param response_format [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  70. #
  71. # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi
  72. #
  73. # @param seed [Integer, nil] This feature is in Beta.
  74. #
  75. # @param service_tier [Symbol, OpenAI::Models::Chat::CompletionCreateParams::ServiceTier, nil] Specifies the processing type used for serving the request.
  76. #
  77. # @param stop [String, Array<String>, nil] Not supported with latest reasoning models `o3` and `o4-mini`.
  78. #
  79. # @param store [Boolean, nil] Whether or not to store the output of this chat completion request for
  80. #
  81. # @param stream_options [OpenAI::Models::Chat::ChatCompletionStreamOptions, nil] Options for streaming response. Only set this when you set `stream: true`.
  82. #
  83. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  84. #
  85. # @param tool_choice [Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionNamedToolChoice] Controls which (if any) tool is called by the model.
  86. #
  87. # @param tools [Array<OpenAI::Models::Chat::ChatCompletionTool>] A list of tools the model may call. Currently, only functions are supported as a
  88. #
  89. # @param top_logprobs [Integer, nil] An integer between 0 and 20 specifying the number of most likely tokens to
  90. #
  91. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling,
  92. #
  93. # @param user [String] This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  94. #
  95. # @param web_search_options [OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions] This tool searches the web for relevant results to use in a response.
  96. #
  97. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  98. #
  99. # @return [OpenAI::Models::Chat::ChatCompletion]
  100. #
  101. # @see OpenAI::Models::Chat::CompletionCreateParams
  102. 1 def create(params)
  103. parsed, options = OpenAI::Chat::CompletionCreateParams.dump_request(params)
  104. then: 0 else: 0 if parsed[:stream]
  105. message = "Please use `#stream_raw` for the streaming use case."
  106. raise ArgumentError.new(message)
  107. end
  108. model = nil
  109. tool_models = {}
  110. case parsed
  111. in: 0 in {response_format: OpenAI::StructuredOutput::JsonSchemaConverter => model}
  112. parsed.update(
  113. response_format: {
  114. type: :json_schema,
  115. json_schema: {
  116. strict: true,
  117. name: model.name.split("::").last,
  118. schema: model.to_json_schema
  119. }
  120. }
  121. )
  122. in: 0 in {response_format: {type: :json_schema, json_schema: OpenAI::StructuredOutput::JsonSchemaConverter => model}}
  123. parsed.fetch(:response_format).update(
  124. json_schema: {
  125. strict: true,
  126. name: model.name.split("::").last,
  127. schema: model.to_json_schema
  128. }
  129. )
  130. in: 0 in {response_format: {type: :json_schema, json_schema: {schema: OpenAI::StructuredOutput::JsonSchemaConverter => model}}}
  131. parsed.dig(:response_format, :json_schema).store(:schema, model.to_json_schema)
  132. in: 0 in {tools: Array => tools}
  133. mapped = tools.map do |tool|
  134. case tool
  135. in: 0 in OpenAI::StructuredOutput::JsonSchemaConverter
  136. name = tool.name.split("::").last
  137. tool_models.store(name, tool)
  138. {
  139. type: :function,
  140. function: {
  141. strict: true,
  142. name: name,
  143. parameters: tool.to_json_schema
  144. }
  145. }
  146. in: 0 in {function: {parameters: OpenAI::StructuredOutput::JsonSchemaConverter => params}}
  147. func = tool.fetch(:function)
  148. name = func[:name] ||= params.name.split("::").last
  149. tool_models.store(name, params)
  150. func.update(parameters: params.to_json_schema)
  151. tool
  152. else: 0 else
  153. tool
  154. end
  155. end
  156. else: 0 tools.replace(mapped)
  157. else
  158. end
  159. # rubocop:disable Metrics/BlockLength
  160. unwrap = ->(raw) do
  161. then: 0 else: 0 if model.is_a?(OpenAI::StructuredOutput::JsonSchemaConverter)
  162. then: 0 else: 0 raw[:choices]&.each do |choice|
  163. message = choice.fetch(:message)
  164. begin
  165. parsed = JSON.parse(message.fetch(:content), symbolize_names: true)
  166. rescue JSON::ParserError => e
  167. parsed = e
  168. end
  169. coerced = OpenAI::Internal::Type::Converter.coerce(model, parsed)
  170. message.store(:parsed, coerced)
  171. end
  172. end
  173. then: 0 else: 0 raw[:choices]&.each do |choice|
  174. then: 0 else: 0 choice.dig(:message, :tool_calls)&.each do |tool_call|
  175. func = tool_call.fetch(:function)
  176. then: 0 else: 0 next if (model = tool_models[func.fetch(:name)]).nil?
  177. begin
  178. parsed = JSON.parse(func.fetch(:arguments), symbolize_names: true)
  179. rescue JSON::ParserError => e
  180. parsed = e
  181. end
  182. coerced = OpenAI::Internal::Type::Converter.coerce(model, parsed)
  183. func.store(:parsed, coerced)
  184. end
  185. end
  186. raw
  187. end
  188. # rubocop:enable Metrics/BlockLength
  189. @client.request(
  190. method: :post,
  191. path: "chat/completions",
  192. body: parsed,
  193. unwrap: unwrap,
  194. model: OpenAI::Chat::ChatCompletion,
  195. options: options
  196. )
  197. end
  198. 1 def stream
  199. raise NotImplementedError.new("higher level helpers are coming soon!")
  200. end
  201. # See {OpenAI::Resources::Chat::Completions#create} for non-streaming counterpart.
  202. #
  203. # Some parameter documentations has been truncated, see
  204. # {OpenAI::Models::Chat::CompletionCreateParams} for more details.
  205. #
  206. # **Starting a new project?** We recommend trying
  207. # [Responses](https://platform.openai.com/docs/api-reference/responses) to take
  208. # advantage of the latest OpenAI platform features. Compare
  209. # [Chat Completions with Responses](https://platform.openai.com/docs/guides/responses-vs-chat-completions?api-mode=responses).
  210. #
  211. # ---
  212. #
  213. # Creates a model response for the given chat conversation. Learn more in the
  214. # [text generation](https://platform.openai.com/docs/guides/text-generation),
  215. # [vision](https://platform.openai.com/docs/guides/vision), and
  216. # [audio](https://platform.openai.com/docs/guides/audio) guides.
  217. #
  218. # Parameter support can differ depending on the model used to generate the
  219. # response, particularly for newer reasoning models. Parameters that are only
  220. # supported for reasoning models are noted below. For the current state of
  221. # unsupported parameters in reasoning models,
  222. # [refer to the reasoning guide](https://platform.openai.com/docs/guides/reasoning).
  223. #
  224. # @overload stream_raw(messages:, model:, audio: nil, frequency_penalty: nil, function_call: nil, functions: nil, logit_bias: nil, logprobs: nil, max_completion_tokens: nil, max_tokens: nil, metadata: nil, modalities: nil, n: nil, parallel_tool_calls: nil, prediction: nil, presence_penalty: nil, prompt_cache_key: nil, reasoning_effort: nil, response_format: nil, safety_identifier: nil, seed: nil, service_tier: nil, stop: nil, store: nil, stream_options: nil, temperature: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, user: nil, web_search_options: nil, request_options: {})
  225. #
  226. # @param messages [Array<OpenAI::Models::Chat::ChatCompletionDeveloperMessageParam, OpenAI::Models::Chat::ChatCompletionSystemMessageParam, OpenAI::Models::Chat::ChatCompletionUserMessageParam, OpenAI::Models::Chat::ChatCompletionAssistantMessageParam, OpenAI::Models::Chat::ChatCompletionToolMessageParam, OpenAI::Models::Chat::ChatCompletionFunctionMessageParam>] A list of messages comprising the conversation so far. Depending on the
  227. #
  228. # @param model [String, Symbol, OpenAI::Models::ChatModel] Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
  229. #
  230. # @param audio [OpenAI::Models::Chat::ChatCompletionAudioParam, nil] Parameters for audio output. Required when audio output is requested with
  231. #
  232. # @param frequency_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on
  233. #
  234. # @param function_call [Symbol, OpenAI::Models::Chat::CompletionCreateParams::FunctionCall::FunctionCallMode, OpenAI::Models::Chat::ChatCompletionFunctionCallOption] Deprecated in favor of `tool_choice`.
  235. #
  236. # @param functions [Array<OpenAI::Models::Chat::CompletionCreateParams::Function>] Deprecated in favor of `tools`.
  237. #
  238. # @param logit_bias [Hash{Symbol=>Integer}, nil] Modify the likelihood of specified tokens appearing in the completion.
  239. #
  240. # @param logprobs [Boolean, nil] Whether to return log probabilities of the output tokens or not. If true,
  241. #
  242. # @param max_completion_tokens [Integer, nil] An upper bound for the number of tokens that can be generated for a completion,
  243. #
  244. # @param max_tokens [Integer, nil] The maximum number of [tokens](/tokenizer) that can be generated in the
  245. #
  246. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  247. #
  248. # @param modalities [Array<Symbol, OpenAI::Models::Chat::CompletionCreateParams::Modality>, nil] Output types that you would like the model to generate.
  249. #
  250. # @param n [Integer, nil] How many chat completion choices to generate for each input message. Note that y
  251. #
  252. # @param parallel_tool_calls [Boolean] Whether to enable [parallel function calling](https://platform.openai.com/docs/g
  253. #
  254. # @param prediction [OpenAI::Models::Chat::ChatCompletionPredictionContent, nil] Static predicted output content, such as the content of a text file that is
  255. #
  256. # @param presence_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on
  257. #
  258. # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi
  259. #
  260. # @param reasoning_effort [Symbol, OpenAI::Models::ReasoningEffort, nil] **o-series models only**
  261. #
  262. # @param response_format [OpenAI::Models::ResponseFormatText, OpenAI::Models::ResponseFormatJSONSchema, OpenAI::Models::ResponseFormatJSONObject] An object specifying the format that the model must output.
  263. #
  264. # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi
  265. #
  266. # @param seed [Integer, nil] This feature is in Beta.
  267. #
  268. # @param service_tier [Symbol, OpenAI::Models::Chat::CompletionCreateParams::ServiceTier, nil] Specifies the processing type used for serving the request.
  269. #
  270. # @param stop [String, Array<String>, nil] Not supported with latest reasoning models `o3` and `o4-mini`.
  271. #
  272. # @param store [Boolean, nil] Whether or not to store the output of this chat completion request for
  273. #
  274. # @param stream_options [OpenAI::Models::Chat::ChatCompletionStreamOptions, nil] Options for streaming response. Only set this when you set `stream: true`.
  275. #
  276. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  277. #
  278. # @param tool_choice [Symbol, OpenAI::Models::Chat::ChatCompletionToolChoiceOption::Auto, OpenAI::Models::Chat::ChatCompletionNamedToolChoice] Controls which (if any) tool is called by the model.
  279. #
  280. # @param tools [Array<OpenAI::Models::Chat::ChatCompletionTool>] A list of tools the model may call. Currently, only functions are supported as a
  281. #
  282. # @param top_logprobs [Integer, nil] An integer between 0 and 20 specifying the number of most likely tokens to
  283. #
  284. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling,
  285. #
  286. # @param user [String] This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  287. #
  288. # @param web_search_options [OpenAI::Models::Chat::CompletionCreateParams::WebSearchOptions] This tool searches the web for relevant results to use in a response.
  289. #
  290. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  291. #
  292. # @return [OpenAI::Internal::Stream<OpenAI::Models::Chat::ChatCompletionChunk>]
  293. #
  294. # @see OpenAI::Models::Chat::CompletionCreateParams
  295. 1 def stream_raw(params)
  296. parsed, options = OpenAI::Chat::CompletionCreateParams.dump_request(params)
  297. else: 0 then: 0 unless parsed.fetch(:stream, true)
  298. message = "Please use `#create` for the non-streaming use case."
  299. raise ArgumentError.new(message)
  300. end
  301. parsed.store(:stream, true)
  302. @client.request(
  303. method: :post,
  304. path: "chat/completions",
  305. headers: {"accept" => "text/event-stream"},
  306. body: parsed,
  307. stream: OpenAI::Internal::Stream,
  308. model: OpenAI::Chat::ChatCompletionChunk,
  309. options: options
  310. )
  311. end
  312. # Get a stored chat completion. Only Chat Completions that have been created with
  313. # the `store` parameter set to `true` will be returned.
  314. #
  315. # @overload retrieve(completion_id, request_options: {})
  316. #
  317. # @param completion_id [String] The ID of the chat completion to retrieve.
  318. #
  319. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  320. #
  321. # @return [OpenAI::Models::Chat::ChatCompletion]
  322. #
  323. # @see OpenAI::Models::Chat::CompletionRetrieveParams
  324. 1 def retrieve(completion_id, params = {})
  325. @client.request(
  326. method: :get,
  327. path: ["chat/completions/%1$s", completion_id],
  328. model: OpenAI::Chat::ChatCompletion,
  329. options: params[:request_options]
  330. )
  331. end
  332. # Some parameter documentations has been truncated, see
  333. # {OpenAI::Models::Chat::CompletionUpdateParams} for more details.
  334. #
  335. # Modify a stored chat completion. Only Chat Completions that have been created
  336. # with the `store` parameter set to `true` can be modified. Currently, the only
  337. # supported modification is to update the `metadata` field.
  338. #
  339. # @overload update(completion_id, metadata:, request_options: {})
  340. #
  341. # @param completion_id [String] The ID of the chat completion to update.
  342. #
  343. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  344. #
  345. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  346. #
  347. # @return [OpenAI::Models::Chat::ChatCompletion]
  348. #
  349. # @see OpenAI::Models::Chat::CompletionUpdateParams
  350. 1 def update(completion_id, params)
  351. parsed, options = OpenAI::Chat::CompletionUpdateParams.dump_request(params)
  352. @client.request(
  353. method: :post,
  354. path: ["chat/completions/%1$s", completion_id],
  355. body: parsed,
  356. model: OpenAI::Chat::ChatCompletion,
  357. options: options
  358. )
  359. end
  360. # Some parameter documentations has been truncated, see
  361. # {OpenAI::Models::Chat::CompletionListParams} for more details.
  362. #
  363. # List stored Chat Completions. Only Chat Completions that have been stored with
  364. # the `store` parameter set to `true` will be returned.
  365. #
  366. # @overload list(after: nil, limit: nil, metadata: nil, model: nil, order: nil, request_options: {})
  367. #
  368. # @param after [String] Identifier for the last chat completion from the previous pagination request.
  369. #
  370. # @param limit [Integer] Number of Chat Completions to retrieve.
  371. #
  372. # @param metadata [Hash{Symbol=>String}, nil] A list of metadata keys to filter the Chat Completions by. Example:
  373. #
  374. # @param model [String] The model used to generate the Chat Completions.
  375. #
  376. # @param order [Symbol, OpenAI::Models::Chat::CompletionListParams::Order] Sort order for Chat Completions by timestamp. Use `asc` for ascending order or `
  377. #
  378. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  379. #
  380. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Chat::ChatCompletion>]
  381. #
  382. # @see OpenAI::Models::Chat::CompletionListParams
  383. 1 def list(params = {})
  384. parsed, options = OpenAI::Chat::CompletionListParams.dump_request(params)
  385. @client.request(
  386. method: :get,
  387. path: "chat/completions",
  388. query: parsed,
  389. page: OpenAI::Internal::CursorPage,
  390. model: OpenAI::Chat::ChatCompletion,
  391. options: options
  392. )
  393. end
  394. # Delete a stored chat completion. Only Chat Completions that have been created
  395. # with the `store` parameter set to `true` can be deleted.
  396. #
  397. # @overload delete(completion_id, request_options: {})
  398. #
  399. # @param completion_id [String] The ID of the chat completion to delete.
  400. #
  401. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  402. #
  403. # @return [OpenAI::Models::Chat::ChatCompletionDeleted]
  404. #
  405. # @see OpenAI::Models::Chat::CompletionDeleteParams
  406. 1 def delete(completion_id, params = {})
  407. @client.request(
  408. method: :delete,
  409. path: ["chat/completions/%1$s", completion_id],
  410. model: OpenAI::Chat::ChatCompletionDeleted,
  411. options: params[:request_options]
  412. )
  413. end
  414. # @api private
  415. #
  416. # @param client [OpenAI::Client]
  417. 1 def initialize(client:)
  418. 2 @client = client
  419. 2 @messages = OpenAI::Resources::Chat::Completions::Messages.new(client: client)
  420. end
  421. end
  422. end
  423. end
  424. end

openai-ruby/lib/openai/resources/chat/completions/messages.rb

80.0% lines covered

100.0% branches covered

10 relevant lines. 8 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Chat
  5. 1 class Completions
  6. 1 class Messages
  7. # Some parameter documentations has been truncated, see
  8. # {OpenAI::Models::Chat::Completions::MessageListParams} for more details.
  9. #
  10. # Get the messages in a stored chat completion. Only Chat Completions that have
  11. # been created with the `store` parameter set to `true` will be returned.
  12. #
  13. # @overload list(completion_id, after: nil, limit: nil, order: nil, request_options: {})
  14. #
  15. # @param completion_id [String] The ID of the chat completion to retrieve messages from.
  16. #
  17. # @param after [String] Identifier for the last message from the previous pagination request.
  18. #
  19. # @param limit [Integer] Number of messages to retrieve.
  20. #
  21. # @param order [Symbol, OpenAI::Models::Chat::Completions::MessageListParams::Order] Sort order for messages by timestamp. Use `asc` for ascending order or `desc` fo
  22. #
  23. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  24. #
  25. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Chat::ChatCompletionStoreMessage>]
  26. #
  27. # @see OpenAI::Models::Chat::Completions::MessageListParams
  28. 1 def list(completion_id, params = {})
  29. parsed, options = OpenAI::Chat::Completions::MessageListParams.dump_request(params)
  30. @client.request(
  31. method: :get,
  32. path: ["chat/completions/%1$s/messages", completion_id],
  33. query: parsed,
  34. page: OpenAI::Internal::CursorPage,
  35. model: OpenAI::Chat::ChatCompletionStoreMessage,
  36. options: options
  37. )
  38. end
  39. # @api private
  40. #
  41. # @param client [OpenAI::Client]
  42. 1 def initialize(client:)
  43. 2 @client = client
  44. end
  45. end
  46. end
  47. end
  48. end
  49. end

openai-ruby/lib/openai/resources/completions.rb

38.89% lines covered

0.0% branches covered

18 relevant lines. 7 lines covered and 11 lines missed.
4 total branches, 0 branches covered and 4 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Completions
  5. # See {OpenAI::Resources::Completions#create_streaming} for streaming counterpart.
  6. #
  7. # Some parameter documentations has been truncated, see
  8. # {OpenAI::Models::CompletionCreateParams} for more details.
  9. #
  10. # Creates a completion for the provided prompt and parameters.
  11. #
  12. # @overload create(model:, prompt:, best_of: nil, echo: nil, frequency_penalty: nil, logit_bias: nil, logprobs: nil, max_tokens: nil, n: nil, presence_penalty: nil, seed: nil, stop: nil, stream_options: nil, suffix: nil, temperature: nil, top_p: nil, user: nil, request_options: {})
  13. #
  14. # @param model [String, Symbol, OpenAI::Models::CompletionCreateParams::Model] ID of the model to use. You can use the [List models](https://platform.openai.co
  15. #
  16. # @param prompt [String, Array<String>, Array<Integer>, Array<Array<Integer>>, nil] The prompt(s) to generate completions for, encoded as a string, array of strings
  17. #
  18. # @param best_of [Integer, nil] Generates `best_of` completions server-side and returns the "best" (the one with
  19. #
  20. # @param echo [Boolean, nil] Echo back the prompt in addition to the completion
  21. #
  22. # @param frequency_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on their
  23. #
  24. # @param logit_bias [Hash{Symbol=>Integer}, nil] Modify the likelihood of specified tokens appearing in the completion.
  25. #
  26. # @param logprobs [Integer, nil] Include the log probabilities on the `logprobs` most likely output tokens, as we
  27. #
  28. # @param max_tokens [Integer, nil] The maximum number of [tokens](/tokenizer) that can be generated in the completi
  29. #
  30. # @param n [Integer, nil] How many completions to generate for each prompt.
  31. #
  32. # @param presence_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on whethe
  33. #
  34. # @param seed [Integer, nil] If specified, our system will make a best effort to sample deterministically, su
  35. #
  36. # @param stop [String, Array<String>, nil] Not supported with latest reasoning models `o3` and `o4-mini`.
  37. #
  38. # @param stream_options [OpenAI::Models::Chat::ChatCompletionStreamOptions, nil] Options for streaming response. Only set this when you set `stream: true`.
  39. #
  40. # @param suffix [String, nil] The suffix that comes after a completion of inserted text.
  41. #
  42. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  43. #
  44. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  45. #
  46. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  47. #
  48. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  49. #
  50. # @return [OpenAI::Models::Completion]
  51. #
  52. # @see OpenAI::Models::CompletionCreateParams
  53. 1 def create(params)
  54. parsed, options = OpenAI::CompletionCreateParams.dump_request(params)
  55. then: 0 else: 0 if parsed[:stream]
  56. message = "Please use `#create_streaming` for the streaming use case."
  57. raise ArgumentError.new(message)
  58. end
  59. @client.request(
  60. method: :post,
  61. path: "completions",
  62. body: parsed,
  63. model: OpenAI::Completion,
  64. options: options
  65. )
  66. end
  67. # See {OpenAI::Resources::Completions#create} for non-streaming counterpart.
  68. #
  69. # Some parameter documentations has been truncated, see
  70. # {OpenAI::Models::CompletionCreateParams} for more details.
  71. #
  72. # Creates a completion for the provided prompt and parameters.
  73. #
  74. # @overload create_streaming(model:, prompt:, best_of: nil, echo: nil, frequency_penalty: nil, logit_bias: nil, logprobs: nil, max_tokens: nil, n: nil, presence_penalty: nil, seed: nil, stop: nil, stream_options: nil, suffix: nil, temperature: nil, top_p: nil, user: nil, request_options: {})
  75. #
  76. # @param model [String, Symbol, OpenAI::Models::CompletionCreateParams::Model] ID of the model to use. You can use the [List models](https://platform.openai.co
  77. #
  78. # @param prompt [String, Array<String>, Array<Integer>, Array<Array<Integer>>, nil] The prompt(s) to generate completions for, encoded as a string, array of strings
  79. #
  80. # @param best_of [Integer, nil] Generates `best_of` completions server-side and returns the "best" (the one with
  81. #
  82. # @param echo [Boolean, nil] Echo back the prompt in addition to the completion
  83. #
  84. # @param frequency_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on their
  85. #
  86. # @param logit_bias [Hash{Symbol=>Integer}, nil] Modify the likelihood of specified tokens appearing in the completion.
  87. #
  88. # @param logprobs [Integer, nil] Include the log probabilities on the `logprobs` most likely output tokens, as we
  89. #
  90. # @param max_tokens [Integer, nil] The maximum number of [tokens](/tokenizer) that can be generated in the completi
  91. #
  92. # @param n [Integer, nil] How many completions to generate for each prompt.
  93. #
  94. # @param presence_penalty [Float, nil] Number between -2.0 and 2.0. Positive values penalize new tokens based on whethe
  95. #
  96. # @param seed [Integer, nil] If specified, our system will make a best effort to sample deterministically, su
  97. #
  98. # @param stop [String, Array<String>, nil] Not supported with latest reasoning models `o3` and `o4-mini`.
  99. #
  100. # @param stream_options [OpenAI::Models::Chat::ChatCompletionStreamOptions, nil] Options for streaming response. Only set this when you set `stream: true`.
  101. #
  102. # @param suffix [String, nil] The suffix that comes after a completion of inserted text.
  103. #
  104. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  105. #
  106. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling, where the
  107. #
  108. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  109. #
  110. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  111. #
  112. # @return [OpenAI::Internal::Stream<OpenAI::Models::Completion>]
  113. #
  114. # @see OpenAI::Models::CompletionCreateParams
  115. 1 def create_streaming(params)
  116. parsed, options = OpenAI::CompletionCreateParams.dump_request(params)
  117. else: 0 then: 0 unless parsed.fetch(:stream, true)
  118. message = "Please use `#create` for the non-streaming use case."
  119. raise ArgumentError.new(message)
  120. end
  121. parsed.store(:stream, true)
  122. @client.request(
  123. method: :post,
  124. path: "completions",
  125. headers: {"accept" => "text/event-stream"},
  126. body: parsed,
  127. stream: OpenAI::Internal::Stream,
  128. model: OpenAI::Completion,
  129. options: options
  130. )
  131. end
  132. # @api private
  133. #
  134. # @param client [OpenAI::Client]
  135. 1 def initialize(client:)
  136. 2 @client = client
  137. end
  138. end
  139. end
  140. end

openai-ruby/lib/openai/resources/containers.rb

64.71% lines covered

100.0% branches covered

17 relevant lines. 11 lines covered and 6 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Containers
  5. # @return [OpenAI::Resources::Containers::Files]
  6. 1 attr_reader :files
  7. # Create Container
  8. #
  9. # @overload create(name:, expires_after: nil, file_ids: nil, request_options: {})
  10. #
  11. # @param name [String] Name of the container to create.
  12. #
  13. # @param expires_after [OpenAI::Models::ContainerCreateParams::ExpiresAfter] Container expiration time in seconds relative to the 'anchor' time.
  14. #
  15. # @param file_ids [Array<String>] IDs of files to copy to the container.
  16. #
  17. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  18. #
  19. # @return [OpenAI::Models::ContainerCreateResponse]
  20. #
  21. # @see OpenAI::Models::ContainerCreateParams
  22. 1 def create(params)
  23. parsed, options = OpenAI::ContainerCreateParams.dump_request(params)
  24. @client.request(
  25. method: :post,
  26. path: "containers",
  27. body: parsed,
  28. model: OpenAI::Models::ContainerCreateResponse,
  29. options: options
  30. )
  31. end
  32. # Retrieve Container
  33. #
  34. # @overload retrieve(container_id, request_options: {})
  35. #
  36. # @param container_id [String]
  37. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  38. #
  39. # @return [OpenAI::Models::ContainerRetrieveResponse]
  40. #
  41. # @see OpenAI::Models::ContainerRetrieveParams
  42. 1 def retrieve(container_id, params = {})
  43. @client.request(
  44. method: :get,
  45. path: ["containers/%1$s", container_id],
  46. model: OpenAI::Models::ContainerRetrieveResponse,
  47. options: params[:request_options]
  48. )
  49. end
  50. # Some parameter documentations has been truncated, see
  51. # {OpenAI::Models::ContainerListParams} for more details.
  52. #
  53. # List Containers
  54. #
  55. # @overload list(after: nil, limit: nil, order: nil, request_options: {})
  56. #
  57. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  58. #
  59. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  60. #
  61. # @param order [Symbol, OpenAI::Models::ContainerListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  62. #
  63. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  64. #
  65. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::ContainerListResponse>]
  66. #
  67. # @see OpenAI::Models::ContainerListParams
  68. 1 def list(params = {})
  69. parsed, options = OpenAI::ContainerListParams.dump_request(params)
  70. @client.request(
  71. method: :get,
  72. path: "containers",
  73. query: parsed,
  74. page: OpenAI::Internal::CursorPage,
  75. model: OpenAI::Models::ContainerListResponse,
  76. options: options
  77. )
  78. end
  79. # Delete Container
  80. #
  81. # @overload delete(container_id, request_options: {})
  82. #
  83. # @param container_id [String] The ID of the container to delete.
  84. #
  85. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  86. #
  87. # @return [nil]
  88. #
  89. # @see OpenAI::Models::ContainerDeleteParams
  90. 1 def delete(container_id, params = {})
  91. @client.request(
  92. method: :delete,
  93. path: ["containers/%1$s", container_id],
  94. model: NilClass,
  95. options: params[:request_options]
  96. )
  97. end
  98. # @api private
  99. #
  100. # @param client [OpenAI::Client]
  101. 1 def initialize(client:)
  102. 2 @client = client
  103. 2 @files = OpenAI::Resources::Containers::Files.new(client: client)
  104. end
  105. end
  106. end
  107. end

openai-ruby/lib/openai/resources/containers/files.rb

50.0% lines covered

100.0% branches covered

24 relevant lines. 12 lines covered and 12 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Containers
  5. 1 class Files
  6. # @return [OpenAI::Resources::Containers::Files::Content]
  7. 1 attr_reader :content
  8. # Some parameter documentations has been truncated, see
  9. # {OpenAI::Models::Containers::FileCreateParams} for more details.
  10. #
  11. # Create a Container File
  12. #
  13. # You can send either a multipart/form-data request with the raw file content, or
  14. # a JSON request with a file ID.
  15. #
  16. # @overload create(container_id, file: nil, file_id: nil, request_options: {})
  17. #
  18. # @param container_id [String]
  19. #
  20. # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The File object (not file name) to be uploaded.
  21. #
  22. # @param file_id [String] Name of the file to create.
  23. #
  24. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  25. #
  26. # @return [OpenAI::Models::Containers::FileCreateResponse]
  27. #
  28. # @see OpenAI::Models::Containers::FileCreateParams
  29. 1 def create(container_id, params = {})
  30. parsed, options = OpenAI::Containers::FileCreateParams.dump_request(params)
  31. @client.request(
  32. method: :post,
  33. path: ["containers/%1$s/files", container_id],
  34. headers: {"content-type" => "multipart/form-data"},
  35. body: parsed,
  36. model: OpenAI::Models::Containers::FileCreateResponse,
  37. options: options
  38. )
  39. end
  40. # Retrieve Container File
  41. #
  42. # @overload retrieve(file_id, container_id:, request_options: {})
  43. #
  44. # @param file_id [String]
  45. # @param container_id [String]
  46. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  47. #
  48. # @return [OpenAI::Models::Containers::FileRetrieveResponse]
  49. #
  50. # @see OpenAI::Models::Containers::FileRetrieveParams
  51. 1 def retrieve(file_id, params)
  52. parsed, options = OpenAI::Containers::FileRetrieveParams.dump_request(params)
  53. container_id =
  54. parsed.delete(:container_id) do
  55. raise ArgumentError.new("missing required path argument #{_1}")
  56. end
  57. @client.request(
  58. method: :get,
  59. path: ["containers/%1$s/files/%2$s", container_id, file_id],
  60. model: OpenAI::Models::Containers::FileRetrieveResponse,
  61. options: options
  62. )
  63. end
  64. # Some parameter documentations has been truncated, see
  65. # {OpenAI::Models::Containers::FileListParams} for more details.
  66. #
  67. # List Container files
  68. #
  69. # @overload list(container_id, after: nil, limit: nil, order: nil, request_options: {})
  70. #
  71. # @param container_id [String]
  72. #
  73. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  74. #
  75. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  76. #
  77. # @param order [Symbol, OpenAI::Models::Containers::FileListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  78. #
  79. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  80. #
  81. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Containers::FileListResponse>]
  82. #
  83. # @see OpenAI::Models::Containers::FileListParams
  84. 1 def list(container_id, params = {})
  85. parsed, options = OpenAI::Containers::FileListParams.dump_request(params)
  86. @client.request(
  87. method: :get,
  88. path: ["containers/%1$s/files", container_id],
  89. query: parsed,
  90. page: OpenAI::Internal::CursorPage,
  91. model: OpenAI::Models::Containers::FileListResponse,
  92. options: options
  93. )
  94. end
  95. # Delete Container File
  96. #
  97. # @overload delete(file_id, container_id:, request_options: {})
  98. #
  99. # @param file_id [String]
  100. # @param container_id [String]
  101. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  102. #
  103. # @return [nil]
  104. #
  105. # @see OpenAI::Models::Containers::FileDeleteParams
  106. 1 def delete(file_id, params)
  107. parsed, options = OpenAI::Containers::FileDeleteParams.dump_request(params)
  108. container_id =
  109. parsed.delete(:container_id) do
  110. raise ArgumentError.new("missing required path argument #{_1}")
  111. end
  112. @client.request(
  113. method: :delete,
  114. path: ["containers/%1$s/files/%2$s", container_id, file_id],
  115. model: NilClass,
  116. options: options
  117. )
  118. end
  119. # @api private
  120. #
  121. # @param client [OpenAI::Client]
  122. 1 def initialize(client:)
  123. 2 @client = client
  124. 2 @content = OpenAI::Resources::Containers::Files::Content.new(client: client)
  125. end
  126. end
  127. end
  128. end
  129. end

openai-ruby/lib/openai/resources/containers/files/content.rb

66.67% lines covered

100.0% branches covered

12 relevant lines. 8 lines covered and 4 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Containers
  5. 1 class Files
  6. 1 class Content
  7. # Retrieve Container File Content
  8. #
  9. # @overload retrieve(file_id, container_id:, request_options: {})
  10. #
  11. # @param file_id [String]
  12. # @param container_id [String]
  13. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  14. #
  15. # @return [StringIO]
  16. #
  17. # @see OpenAI::Models::Containers::Files::ContentRetrieveParams
  18. 1 def retrieve(file_id, params)
  19. parsed, options = OpenAI::Containers::Files::ContentRetrieveParams.dump_request(params)
  20. container_id =
  21. parsed.delete(:container_id) do
  22. raise ArgumentError.new("missing required path argument #{_1}")
  23. end
  24. @client.request(
  25. method: :get,
  26. path: ["containers/%1$s/files/%2$s/content", container_id, file_id],
  27. headers: {"accept" => "application/binary"},
  28. model: StringIO,
  29. options: options
  30. )
  31. end
  32. # @api private
  33. #
  34. # @param client [OpenAI::Client]
  35. 1 def initialize(client:)
  36. 2 @client = client
  37. end
  38. end
  39. end
  40. end
  41. end
  42. end

openai-ruby/lib/openai/resources/embeddings.rb

75.0% lines covered

100.0% branches covered

8 relevant lines. 6 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Embeddings
  5. # Some parameter documentations has been truncated, see
  6. # {OpenAI::Models::EmbeddingCreateParams} for more details.
  7. #
  8. # Creates an embedding vector representing the input text.
  9. #
  10. # @overload create(input:, model:, dimensions: nil, encoding_format: nil, user: nil, request_options: {})
  11. #
  12. # @param input [String, Array<String>, Array<Integer>, Array<Array<Integer>>] Input text to embed, encoded as a string or array of tokens. To embed multiple i
  13. #
  14. # @param model [String, Symbol, OpenAI::Models::EmbeddingModel] ID of the model to use. You can use the [List models](https://platform.openai.co
  15. #
  16. # @param dimensions [Integer] The number of dimensions the resulting output embeddings should have. Only suppo
  17. #
  18. # @param encoding_format [Symbol, OpenAI::Models::EmbeddingCreateParams::EncodingFormat] The format to return the embeddings in. Can be either `float` or [`base64`](http
  19. #
  20. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  21. #
  22. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  23. #
  24. # @return [OpenAI::Models::CreateEmbeddingResponse]
  25. #
  26. # @see OpenAI::Models::EmbeddingCreateParams
  27. 1 def create(params)
  28. parsed, options = OpenAI::EmbeddingCreateParams.dump_request(params)
  29. @client.request(
  30. method: :post,
  31. path: "embeddings",
  32. body: parsed,
  33. model: OpenAI::CreateEmbeddingResponse,
  34. options: options
  35. )
  36. end
  37. # @api private
  38. #
  39. # @param client [OpenAI::Client]
  40. 1 def initialize(client:)
  41. 2 @client = client
  42. end
  43. end
  44. end
  45. end

openai-ruby/lib/openai/resources/evals.rb

60.0% lines covered

100.0% branches covered

20 relevant lines. 12 lines covered and 8 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Evals
  5. # @return [OpenAI::Resources::Evals::Runs]
  6. 1 attr_reader :runs
  7. # Some parameter documentations has been truncated, see
  8. # {OpenAI::Models::EvalCreateParams} for more details.
  9. #
  10. # Create the structure of an evaluation that can be used to test a model's
  11. # performance. An evaluation is a set of testing criteria and the config for a
  12. # data source, which dictates the schema of the data used in the evaluation. After
  13. # creating an evaluation, you can run it on different models and model parameters.
  14. # We support several types of graders and datasources. For more information, see
  15. # the [Evals guide](https://platform.openai.com/docs/guides/evals).
  16. #
  17. # @overload create(data_source_config:, testing_criteria:, metadata: nil, name: nil, request_options: {})
  18. #
  19. # @param data_source_config [OpenAI::Models::EvalCreateParams::DataSourceConfig::Custom, OpenAI::Models::EvalCreateParams::DataSourceConfig::Logs, OpenAI::Models::EvalCreateParams::DataSourceConfig::StoredCompletions] The configuration for the data source used for the evaluation runs. Dictates the
  20. #
  21. # @param testing_criteria [Array<OpenAI::Models::EvalCreateParams::TestingCriterion::LabelModel, OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::EvalCreateParams::TestingCriterion::TextSimilarity, OpenAI::Models::EvalCreateParams::TestingCriterion::Python, OpenAI::Models::EvalCreateParams::TestingCriterion::ScoreModel>] A list of graders for all eval runs in this group. Graders can reference variabl
  22. #
  23. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  24. #
  25. # @param name [String] The name of the evaluation.
  26. #
  27. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  28. #
  29. # @return [OpenAI::Models::EvalCreateResponse]
  30. #
  31. # @see OpenAI::Models::EvalCreateParams
  32. 1 def create(params)
  33. parsed, options = OpenAI::EvalCreateParams.dump_request(params)
  34. @client.request(
  35. method: :post,
  36. path: "evals",
  37. body: parsed,
  38. model: OpenAI::Models::EvalCreateResponse,
  39. options: options
  40. )
  41. end
  42. # Get an evaluation by ID.
  43. #
  44. # @overload retrieve(eval_id, request_options: {})
  45. #
  46. # @param eval_id [String] The ID of the evaluation to retrieve.
  47. #
  48. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  49. #
  50. # @return [OpenAI::Models::EvalRetrieveResponse]
  51. #
  52. # @see OpenAI::Models::EvalRetrieveParams
  53. 1 def retrieve(eval_id, params = {})
  54. @client.request(
  55. method: :get,
  56. path: ["evals/%1$s", eval_id],
  57. model: OpenAI::Models::EvalRetrieveResponse,
  58. options: params[:request_options]
  59. )
  60. end
  61. # Some parameter documentations has been truncated, see
  62. # {OpenAI::Models::EvalUpdateParams} for more details.
  63. #
  64. # Update certain properties of an evaluation.
  65. #
  66. # @overload update(eval_id, metadata: nil, name: nil, request_options: {})
  67. #
  68. # @param eval_id [String] The ID of the evaluation to update.
  69. #
  70. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  71. #
  72. # @param name [String] Rename the evaluation.
  73. #
  74. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  75. #
  76. # @return [OpenAI::Models::EvalUpdateResponse]
  77. #
  78. # @see OpenAI::Models::EvalUpdateParams
  79. 1 def update(eval_id, params = {})
  80. parsed, options = OpenAI::EvalUpdateParams.dump_request(params)
  81. @client.request(
  82. method: :post,
  83. path: ["evals/%1$s", eval_id],
  84. body: parsed,
  85. model: OpenAI::Models::EvalUpdateResponse,
  86. options: options
  87. )
  88. end
  89. # Some parameter documentations has been truncated, see
  90. # {OpenAI::Models::EvalListParams} for more details.
  91. #
  92. # List evaluations for a project.
  93. #
  94. # @overload list(after: nil, limit: nil, order: nil, order_by: nil, request_options: {})
  95. #
  96. # @param after [String] Identifier for the last eval from the previous pagination request.
  97. #
  98. # @param limit [Integer] Number of evals to retrieve.
  99. #
  100. # @param order [Symbol, OpenAI::Models::EvalListParams::Order] Sort order for evals by timestamp. Use `asc` for ascending order or `desc` for d
  101. #
  102. # @param order_by [Symbol, OpenAI::Models::EvalListParams::OrderBy] Evals can be ordered by creation time or last updated time. Use
  103. #
  104. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  105. #
  106. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::EvalListResponse>]
  107. #
  108. # @see OpenAI::Models::EvalListParams
  109. 1 def list(params = {})
  110. parsed, options = OpenAI::EvalListParams.dump_request(params)
  111. @client.request(
  112. method: :get,
  113. path: "evals",
  114. query: parsed,
  115. page: OpenAI::Internal::CursorPage,
  116. model: OpenAI::Models::EvalListResponse,
  117. options: options
  118. )
  119. end
  120. # Delete an evaluation.
  121. #
  122. # @overload delete(eval_id, request_options: {})
  123. #
  124. # @param eval_id [String] The ID of the evaluation to delete.
  125. #
  126. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  127. #
  128. # @return [OpenAI::Models::EvalDeleteResponse]
  129. #
  130. # @see OpenAI::Models::EvalDeleteParams
  131. 1 def delete(eval_id, params = {})
  132. @client.request(
  133. method: :delete,
  134. path: ["evals/%1$s", eval_id],
  135. model: OpenAI::Models::EvalDeleteResponse,
  136. options: params[:request_options]
  137. )
  138. end
  139. # @api private
  140. #
  141. # @param client [OpenAI::Client]
  142. 1 def initialize(client:)
  143. 2 @client = client
  144. 2 @runs = OpenAI::Resources::Evals::Runs.new(client: client)
  145. end
  146. end
  147. end
  148. end

openai-ruby/lib/openai/resources/evals/runs.rb

44.83% lines covered

100.0% branches covered

29 relevant lines. 13 lines covered and 16 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Evals
  5. 1 class Runs
  6. # @return [OpenAI::Resources::Evals::Runs::OutputItems]
  7. 1 attr_reader :output_items
  8. # Some parameter documentations has been truncated, see
  9. # {OpenAI::Models::Evals::RunCreateParams} for more details.
  10. #
  11. # Kicks off a new run for a given evaluation, specifying the data source, and what
  12. # model configuration to use to test. The datasource will be validated against the
  13. # schema specified in the config of the evaluation.
  14. #
  15. # @overload create(eval_id, data_source:, metadata: nil, name: nil, request_options: {})
  16. #
  17. # @param eval_id [String] The ID of the evaluation to create a run for.
  18. #
  19. # @param data_source [OpenAI::Models::Evals::CreateEvalJSONLRunDataSource, OpenAI::Models::Evals::CreateEvalCompletionsRunDataSource, OpenAI::Models::Evals::RunCreateParams::DataSource::CreateEvalResponsesRunDataSource] Details about the run's data source.
  20. #
  21. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  22. #
  23. # @param name [String] The name of the run.
  24. #
  25. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  26. #
  27. # @return [OpenAI::Models::Evals::RunCreateResponse]
  28. #
  29. # @see OpenAI::Models::Evals::RunCreateParams
  30. 1 def create(eval_id, params)
  31. parsed, options = OpenAI::Evals::RunCreateParams.dump_request(params)
  32. @client.request(
  33. method: :post,
  34. path: ["evals/%1$s/runs", eval_id],
  35. body: parsed,
  36. model: OpenAI::Models::Evals::RunCreateResponse,
  37. options: options
  38. )
  39. end
  40. # Get an evaluation run by ID.
  41. #
  42. # @overload retrieve(run_id, eval_id:, request_options: {})
  43. #
  44. # @param run_id [String] The ID of the run to retrieve.
  45. #
  46. # @param eval_id [String] The ID of the evaluation to retrieve runs for.
  47. #
  48. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  49. #
  50. # @return [OpenAI::Models::Evals::RunRetrieveResponse]
  51. #
  52. # @see OpenAI::Models::Evals::RunRetrieveParams
  53. 1 def retrieve(run_id, params)
  54. parsed, options = OpenAI::Evals::RunRetrieveParams.dump_request(params)
  55. eval_id =
  56. parsed.delete(:eval_id) do
  57. raise ArgumentError.new("missing required path argument #{_1}")
  58. end
  59. @client.request(
  60. method: :get,
  61. path: ["evals/%1$s/runs/%2$s", eval_id, run_id],
  62. model: OpenAI::Models::Evals::RunRetrieveResponse,
  63. options: options
  64. )
  65. end
  66. # Some parameter documentations has been truncated, see
  67. # {OpenAI::Models::Evals::RunListParams} for more details.
  68. #
  69. # Get a list of runs for an evaluation.
  70. #
  71. # @overload list(eval_id, after: nil, limit: nil, order: nil, status: nil, request_options: {})
  72. #
  73. # @param eval_id [String] The ID of the evaluation to retrieve runs for.
  74. #
  75. # @param after [String] Identifier for the last run from the previous pagination request.
  76. #
  77. # @param limit [Integer] Number of runs to retrieve.
  78. #
  79. # @param order [Symbol, OpenAI::Models::Evals::RunListParams::Order] Sort order for runs by timestamp. Use `asc` for ascending order or `desc` for de
  80. #
  81. # @param status [Symbol, OpenAI::Models::Evals::RunListParams::Status] Filter runs by status. One of `queued` | `in_progress` | `failed` | `completed`
  82. #
  83. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  84. #
  85. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Evals::RunListResponse>]
  86. #
  87. # @see OpenAI::Models::Evals::RunListParams
  88. 1 def list(eval_id, params = {})
  89. parsed, options = OpenAI::Evals::RunListParams.dump_request(params)
  90. @client.request(
  91. method: :get,
  92. path: ["evals/%1$s/runs", eval_id],
  93. query: parsed,
  94. page: OpenAI::Internal::CursorPage,
  95. model: OpenAI::Models::Evals::RunListResponse,
  96. options: options
  97. )
  98. end
  99. # Delete an eval run.
  100. #
  101. # @overload delete(run_id, eval_id:, request_options: {})
  102. #
  103. # @param run_id [String] The ID of the run to delete.
  104. #
  105. # @param eval_id [String] The ID of the evaluation to delete the run from.
  106. #
  107. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  108. #
  109. # @return [OpenAI::Models::Evals::RunDeleteResponse]
  110. #
  111. # @see OpenAI::Models::Evals::RunDeleteParams
  112. 1 def delete(run_id, params)
  113. parsed, options = OpenAI::Evals::RunDeleteParams.dump_request(params)
  114. eval_id =
  115. parsed.delete(:eval_id) do
  116. raise ArgumentError.new("missing required path argument #{_1}")
  117. end
  118. @client.request(
  119. method: :delete,
  120. path: ["evals/%1$s/runs/%2$s", eval_id, run_id],
  121. model: OpenAI::Models::Evals::RunDeleteResponse,
  122. options: options
  123. )
  124. end
  125. # Cancel an ongoing evaluation run.
  126. #
  127. # @overload cancel(run_id, eval_id:, request_options: {})
  128. #
  129. # @param run_id [String] The ID of the run to cancel.
  130. #
  131. # @param eval_id [String] The ID of the evaluation whose run you want to cancel.
  132. #
  133. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  134. #
  135. # @return [OpenAI::Models::Evals::RunCancelResponse]
  136. #
  137. # @see OpenAI::Models::Evals::RunCancelParams
  138. 1 def cancel(run_id, params)
  139. parsed, options = OpenAI::Evals::RunCancelParams.dump_request(params)
  140. eval_id =
  141. parsed.delete(:eval_id) do
  142. raise ArgumentError.new("missing required path argument #{_1}")
  143. end
  144. @client.request(
  145. method: :post,
  146. path: ["evals/%1$s/runs/%2$s", eval_id, run_id],
  147. model: OpenAI::Models::Evals::RunCancelResponse,
  148. options: options
  149. )
  150. end
  151. # @api private
  152. #
  153. # @param client [OpenAI::Client]
  154. 1 def initialize(client:)
  155. 2 @client = client
  156. 2 @output_items = OpenAI::Resources::Evals::Runs::OutputItems.new(client: client)
  157. end
  158. end
  159. end
  160. end
  161. end

openai-ruby/lib/openai/resources/evals/runs/output_items.rb

47.37% lines covered

100.0% branches covered

19 relevant lines. 9 lines covered and 10 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Evals
  5. 1 class Runs
  6. 1 class OutputItems
  7. # Get an evaluation run output item by ID.
  8. #
  9. # @overload retrieve(output_item_id, eval_id:, run_id:, request_options: {})
  10. #
  11. # @param output_item_id [String] The ID of the output item to retrieve.
  12. #
  13. # @param eval_id [String] The ID of the evaluation to retrieve runs for.
  14. #
  15. # @param run_id [String] The ID of the run to retrieve.
  16. #
  17. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  18. #
  19. # @return [OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse]
  20. #
  21. # @see OpenAI::Models::Evals::Runs::OutputItemRetrieveParams
  22. 1 def retrieve(output_item_id, params)
  23. parsed, options = OpenAI::Evals::Runs::OutputItemRetrieveParams.dump_request(params)
  24. eval_id =
  25. parsed.delete(:eval_id) do
  26. raise ArgumentError.new("missing required path argument #{_1}")
  27. end
  28. run_id =
  29. parsed.delete(:run_id) do
  30. raise ArgumentError.new("missing required path argument #{_1}")
  31. end
  32. @client.request(
  33. method: :get,
  34. path: ["evals/%1$s/runs/%2$s/output_items/%3$s", eval_id, run_id, output_item_id],
  35. model: OpenAI::Models::Evals::Runs::OutputItemRetrieveResponse,
  36. options: options
  37. )
  38. end
  39. # Some parameter documentations has been truncated, see
  40. # {OpenAI::Models::Evals::Runs::OutputItemListParams} for more details.
  41. #
  42. # Get a list of output items for an evaluation run.
  43. #
  44. # @overload list(run_id, eval_id:, after: nil, limit: nil, order: nil, status: nil, request_options: {})
  45. #
  46. # @param run_id [String] Path param: The ID of the run to retrieve output items for.
  47. #
  48. # @param eval_id [String] Path param: The ID of the evaluation to retrieve runs for.
  49. #
  50. # @param after [String] Query param: Identifier for the last output item from the previous pagination re
  51. #
  52. # @param limit [Integer] Query param: Number of output items to retrieve.
  53. #
  54. # @param order [Symbol, OpenAI::Models::Evals::Runs::OutputItemListParams::Order] Query param: Sort order for output items by timestamp. Use `asc` for ascending o
  55. #
  56. # @param status [Symbol, OpenAI::Models::Evals::Runs::OutputItemListParams::Status] Query param: Filter output items by status. Use `failed` to filter by failed out
  57. #
  58. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  59. #
  60. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Evals::Runs::OutputItemListResponse>]
  61. #
  62. # @see OpenAI::Models::Evals::Runs::OutputItemListParams
  63. 1 def list(run_id, params)
  64. parsed, options = OpenAI::Evals::Runs::OutputItemListParams.dump_request(params)
  65. eval_id =
  66. parsed.delete(:eval_id) do
  67. raise ArgumentError.new("missing required path argument #{_1}")
  68. end
  69. @client.request(
  70. method: :get,
  71. path: ["evals/%1$s/runs/%2$s/output_items", eval_id, run_id],
  72. query: parsed,
  73. page: OpenAI::Internal::CursorPage,
  74. model: OpenAI::Models::Evals::Runs::OutputItemListResponse,
  75. options: options
  76. )
  77. end
  78. # @api private
  79. #
  80. # @param client [OpenAI::Client]
  81. 1 def initialize(client:)
  82. 2 @client = client
  83. end
  84. end
  85. end
  86. end
  87. end
  88. end

openai-ruby/lib/openai/resources/files.rb

58.82% lines covered

100.0% branches covered

17 relevant lines. 10 lines covered and 7 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Files
  5. # Some parameter documentations has been truncated, see
  6. # {OpenAI::Models::FileCreateParams} for more details.
  7. #
  8. # Upload a file that can be used across various endpoints. Individual files can be
  9. # up to 512 MB, and the size of all files uploaded by one organization can be up
  10. # to 100 GB.
  11. #
  12. # The Assistants API supports files up to 2 million tokens and of specific file
  13. # types. See the
  14. # [Assistants Tools guide](https://platform.openai.com/docs/assistants/tools) for
  15. # details.
  16. #
  17. # The Fine-tuning API only supports `.jsonl` files. The input also has certain
  18. # required formats for fine-tuning
  19. # [chat](https://platform.openai.com/docs/api-reference/fine-tuning/chat-input) or
  20. # [completions](https://platform.openai.com/docs/api-reference/fine-tuning/completions-input)
  21. # models.
  22. #
  23. # The Batch API only supports `.jsonl` files up to 200 MB in size. The input also
  24. # has a specific required
  25. # [format](https://platform.openai.com/docs/api-reference/batch/request-input).
  26. #
  27. # Please [contact us](https://help.openai.com/) if you need to increase these
  28. # storage limits.
  29. #
  30. # @overload create(file:, purpose:, request_options: {})
  31. #
  32. # @param file [Pathname, StringIO, IO, String, OpenAI::FilePart] The File object (not file name) to be uploaded.
  33. #
  34. # @param purpose [Symbol, OpenAI::Models::FilePurpose] The intended purpose of the uploaded file. One of: - `assistants`: Used in the A
  35. #
  36. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  37. #
  38. # @return [OpenAI::Models::FileObject]
  39. #
  40. # @see OpenAI::Models::FileCreateParams
  41. 1 def create(params)
  42. parsed, options = OpenAI::FileCreateParams.dump_request(params)
  43. @client.request(
  44. method: :post,
  45. path: "files",
  46. headers: {"content-type" => "multipart/form-data"},
  47. body: parsed,
  48. model: OpenAI::FileObject,
  49. options: options
  50. )
  51. end
  52. # Returns information about a specific file.
  53. #
  54. # @overload retrieve(file_id, request_options: {})
  55. #
  56. # @param file_id [String] The ID of the file to use for this request.
  57. #
  58. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  59. #
  60. # @return [OpenAI::Models::FileObject]
  61. #
  62. # @see OpenAI::Models::FileRetrieveParams
  63. 1 def retrieve(file_id, params = {})
  64. @client.request(
  65. method: :get,
  66. path: ["files/%1$s", file_id],
  67. model: OpenAI::FileObject,
  68. options: params[:request_options]
  69. )
  70. end
  71. # Some parameter documentations has been truncated, see
  72. # {OpenAI::Models::FileListParams} for more details.
  73. #
  74. # Returns a list of files.
  75. #
  76. # @overload list(after: nil, limit: nil, order: nil, purpose: nil, request_options: {})
  77. #
  78. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  79. #
  80. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  81. #
  82. # @param order [Symbol, OpenAI::Models::FileListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  83. #
  84. # @param purpose [String] Only return files with the given purpose.
  85. #
  86. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  87. #
  88. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::FileObject>]
  89. #
  90. # @see OpenAI::Models::FileListParams
  91. 1 def list(params = {})
  92. parsed, options = OpenAI::FileListParams.dump_request(params)
  93. @client.request(
  94. method: :get,
  95. path: "files",
  96. query: parsed,
  97. page: OpenAI::Internal::CursorPage,
  98. model: OpenAI::FileObject,
  99. options: options
  100. )
  101. end
  102. # Delete a file.
  103. #
  104. # @overload delete(file_id, request_options: {})
  105. #
  106. # @param file_id [String] The ID of the file to use for this request.
  107. #
  108. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  109. #
  110. # @return [OpenAI::Models::FileDeleted]
  111. #
  112. # @see OpenAI::Models::FileDeleteParams
  113. 1 def delete(file_id, params = {})
  114. @client.request(
  115. method: :delete,
  116. path: ["files/%1$s", file_id],
  117. model: OpenAI::FileDeleted,
  118. options: params[:request_options]
  119. )
  120. end
  121. # Returns the contents of the specified file.
  122. #
  123. # @overload content(file_id, request_options: {})
  124. #
  125. # @param file_id [String] The ID of the file to use for this request.
  126. #
  127. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  128. #
  129. # @return [StringIO]
  130. #
  131. # @see OpenAI::Models::FileContentParams
  132. 1 def content(file_id, params = {})
  133. @client.request(
  134. method: :get,
  135. path: ["files/%1$s/content", file_id],
  136. headers: {"accept" => "application/binary"},
  137. model: StringIO,
  138. options: params[:request_options]
  139. )
  140. end
  141. # @api private
  142. #
  143. # @param client [OpenAI::Client]
  144. 1 def initialize(client:)
  145. 2 @client = client
  146. end
  147. end
  148. end
  149. end

openai-ruby/lib/openai/resources/fine_tuning.rb

100.0% lines covered

100.0% branches covered

13 relevant lines. 13 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class FineTuning
  5. # @return [OpenAI::Resources::FineTuning::Methods]
  6. 1 attr_reader :methods_
  7. # @return [OpenAI::Resources::FineTuning::Jobs]
  8. 1 attr_reader :jobs
  9. # @return [OpenAI::Resources::FineTuning::Checkpoints]
  10. 1 attr_reader :checkpoints
  11. # @return [OpenAI::Resources::FineTuning::Alpha]
  12. 1 attr_reader :alpha
  13. # @api private
  14. #
  15. # @param client [OpenAI::Client]
  16. 1 def initialize(client:)
  17. 2 @client = client
  18. 2 @methods_ = OpenAI::Resources::FineTuning::Methods.new(client: client)
  19. 2 @jobs = OpenAI::Resources::FineTuning::Jobs.new(client: client)
  20. 2 @checkpoints = OpenAI::Resources::FineTuning::Checkpoints.new(client: client)
  21. 2 @alpha = OpenAI::Resources::FineTuning::Alpha.new(client: client)
  22. end
  23. end
  24. end
  25. end

openai-ruby/lib/openai/resources/fine_tuning/alpha.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class FineTuning
  5. 1 class Alpha
  6. # @return [OpenAI::Resources::FineTuning::Alpha::Graders]
  7. 1 attr_reader :graders
  8. # @api private
  9. #
  10. # @param client [OpenAI::Client]
  11. 1 def initialize(client:)
  12. 2 @client = client
  13. 2 @graders = OpenAI::Resources::FineTuning::Alpha::Graders.new(client: client)
  14. end
  15. end
  16. end
  17. end
  18. end

openai-ruby/lib/openai/resources/fine_tuning/alpha/graders.rb

69.23% lines covered

100.0% branches covered

13 relevant lines. 9 lines covered and 4 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class FineTuning
  5. 1 class Alpha
  6. 1 class Graders
  7. # Some parameter documentations has been truncated, see
  8. # {OpenAI::Models::FineTuning::Alpha::GraderRunParams} for more details.
  9. #
  10. # Run a grader.
  11. #
  12. # @overload run(grader:, model_sample:, item: nil, request_options: {})
  13. #
  14. # @param grader [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader] The grader used for the fine-tuning job.
  15. #
  16. # @param model_sample [String] The model sample to be evaluated. This value will be used to populate
  17. #
  18. # @param item [Object] The dataset item provided to the grader. This will be used to populate
  19. #
  20. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  21. #
  22. # @return [OpenAI::Models::FineTuning::Alpha::GraderRunResponse]
  23. #
  24. # @see OpenAI::Models::FineTuning::Alpha::GraderRunParams
  25. 1 def run(params)
  26. parsed, options = OpenAI::FineTuning::Alpha::GraderRunParams.dump_request(params)
  27. @client.request(
  28. method: :post,
  29. path: "fine_tuning/alpha/graders/run",
  30. body: parsed,
  31. model: OpenAI::Models::FineTuning::Alpha::GraderRunResponse,
  32. options: options
  33. )
  34. end
  35. # Validate a grader.
  36. #
  37. # @overload validate(grader:, request_options: {})
  38. #
  39. # @param grader [OpenAI::Models::Graders::StringCheckGrader, OpenAI::Models::Graders::TextSimilarityGrader, OpenAI::Models::Graders::PythonGrader, OpenAI::Models::Graders::ScoreModelGrader, OpenAI::Models::Graders::MultiGrader] The grader used for the fine-tuning job.
  40. #
  41. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  42. #
  43. # @return [OpenAI::Models::FineTuning::Alpha::GraderValidateResponse]
  44. #
  45. # @see OpenAI::Models::FineTuning::Alpha::GraderValidateParams
  46. 1 def validate(params)
  47. parsed, options = OpenAI::FineTuning::Alpha::GraderValidateParams.dump_request(params)
  48. @client.request(
  49. method: :post,
  50. path: "fine_tuning/alpha/graders/validate",
  51. body: parsed,
  52. model: OpenAI::Models::FineTuning::Alpha::GraderValidateResponse,
  53. options: options
  54. )
  55. end
  56. # @api private
  57. #
  58. # @param client [OpenAI::Client]
  59. 1 def initialize(client:)
  60. 2 @client = client
  61. end
  62. end
  63. end
  64. end
  65. end
  66. end

openai-ruby/lib/openai/resources/fine_tuning/checkpoints.rb

100.0% lines covered

100.0% branches covered

8 relevant lines. 8 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class FineTuning
  5. 1 class Checkpoints
  6. # @return [OpenAI::Resources::FineTuning::Checkpoints::Permissions]
  7. 1 attr_reader :permissions
  8. # @api private
  9. #
  10. # @param client [OpenAI::Client]
  11. 1 def initialize(client:)
  12. 2 @client = client
  13. 2 @permissions = OpenAI::Resources::FineTuning::Checkpoints::Permissions.new(client: client)
  14. end
  15. end
  16. end
  17. end
  18. end

openai-ruby/lib/openai/resources/fine_tuning/checkpoints/permissions.rb

55.56% lines covered

100.0% branches covered

18 relevant lines. 10 lines covered and 8 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class FineTuning
  5. 1 class Checkpoints
  6. 1 class Permissions
  7. # Some parameter documentations has been truncated, see
  8. # {OpenAI::Models::FineTuning::Checkpoints::PermissionCreateParams} for more
  9. # details.
  10. #
  11. # **NOTE:** Calling this endpoint requires an [admin API key](../admin-api-keys).
  12. #
  13. # This enables organization owners to share fine-tuned models with other projects
  14. # in their organization.
  15. #
  16. # @overload create(fine_tuned_model_checkpoint, project_ids:, request_options: {})
  17. #
  18. # @param fine_tuned_model_checkpoint [String] The ID of the fine-tuned model checkpoint to create a permission for.
  19. #
  20. # @param project_ids [Array<String>] The project identifiers to grant access to.
  21. #
  22. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  23. #
  24. # @return [OpenAI::Internal::Page<OpenAI::Models::FineTuning::Checkpoints::PermissionCreateResponse>]
  25. #
  26. # @see OpenAI::Models::FineTuning::Checkpoints::PermissionCreateParams
  27. 1 def create(fine_tuned_model_checkpoint, params)
  28. parsed, options = OpenAI::FineTuning::Checkpoints::PermissionCreateParams.dump_request(params)
  29. @client.request(
  30. method: :post,
  31. path: ["fine_tuning/checkpoints/%1$s/permissions", fine_tuned_model_checkpoint],
  32. body: parsed,
  33. page: OpenAI::Internal::Page,
  34. model: OpenAI::Models::FineTuning::Checkpoints::PermissionCreateResponse,
  35. options: options
  36. )
  37. end
  38. # Some parameter documentations has been truncated, see
  39. # {OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveParams} for more
  40. # details.
  41. #
  42. # **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
  43. #
  44. # Organization owners can use this endpoint to view all permissions for a
  45. # fine-tuned model checkpoint.
  46. #
  47. # @overload retrieve(fine_tuned_model_checkpoint, after: nil, limit: nil, order: nil, project_id: nil, request_options: {})
  48. #
  49. # @param fine_tuned_model_checkpoint [String] The ID of the fine-tuned model checkpoint to get permissions for.
  50. #
  51. # @param after [String] Identifier for the last permission ID from the previous pagination request.
  52. #
  53. # @param limit [Integer] Number of permissions to retrieve.
  54. #
  55. # @param order [Symbol, OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveParams::Order] The order in which to retrieve permissions.
  56. #
  57. # @param project_id [String] The ID of the project to get permissions for.
  58. #
  59. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  60. #
  61. # @return [OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveResponse]
  62. #
  63. # @see OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveParams
  64. 1 def retrieve(fine_tuned_model_checkpoint, params = {})
  65. parsed, options = OpenAI::FineTuning::Checkpoints::PermissionRetrieveParams.dump_request(params)
  66. @client.request(
  67. method: :get,
  68. path: ["fine_tuning/checkpoints/%1$s/permissions", fine_tuned_model_checkpoint],
  69. query: parsed,
  70. model: OpenAI::Models::FineTuning::Checkpoints::PermissionRetrieveResponse,
  71. options: options
  72. )
  73. end
  74. # Some parameter documentations has been truncated, see
  75. # {OpenAI::Models::FineTuning::Checkpoints::PermissionDeleteParams} for more
  76. # details.
  77. #
  78. # **NOTE:** This endpoint requires an [admin API key](../admin-api-keys).
  79. #
  80. # Organization owners can use this endpoint to delete a permission for a
  81. # fine-tuned model checkpoint.
  82. #
  83. # @overload delete(permission_id, fine_tuned_model_checkpoint:, request_options: {})
  84. #
  85. # @param permission_id [String] The ID of the fine-tuned model checkpoint permission to delete.
  86. #
  87. # @param fine_tuned_model_checkpoint [String] The ID of the fine-tuned model checkpoint to delete a permission for.
  88. #
  89. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  90. #
  91. # @return [OpenAI::Models::FineTuning::Checkpoints::PermissionDeleteResponse]
  92. #
  93. # @see OpenAI::Models::FineTuning::Checkpoints::PermissionDeleteParams
  94. 1 def delete(permission_id, params)
  95. parsed, options = OpenAI::FineTuning::Checkpoints::PermissionDeleteParams.dump_request(params)
  96. fine_tuned_model_checkpoint =
  97. parsed.delete(:fine_tuned_model_checkpoint) do
  98. raise ArgumentError.new("missing required path argument #{_1}")
  99. end
  100. @client.request(
  101. method: :delete,
  102. path: [
  103. "fine_tuning/checkpoints/%1$s/permissions/%2$s",
  104. fine_tuned_model_checkpoint,
  105. permission_id
  106. ],
  107. model: OpenAI::Models::FineTuning::Checkpoints::PermissionDeleteResponse,
  108. options: options
  109. )
  110. end
  111. # @api private
  112. #
  113. # @param client [OpenAI::Client]
  114. 1 def initialize(client:)
  115. 2 @client = client
  116. end
  117. end
  118. end
  119. end
  120. end
  121. end

openai-ruby/lib/openai/resources/fine_tuning/jobs.rb

60.0% lines covered

100.0% branches covered

25 relevant lines. 15 lines covered and 10 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class FineTuning
  5. 1 class Jobs
  6. # @return [OpenAI::Resources::FineTuning::Jobs::Checkpoints]
  7. 1 attr_reader :checkpoints
  8. # Some parameter documentations has been truncated, see
  9. # {OpenAI::Models::FineTuning::JobCreateParams} for more details.
  10. #
  11. # Creates a fine-tuning job which begins the process of creating a new model from
  12. # a given dataset.
  13. #
  14. # Response includes details of the enqueued job including job status and the name
  15. # of the fine-tuned models once complete.
  16. #
  17. # [Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)
  18. #
  19. # @overload create(model:, training_file:, hyperparameters: nil, integrations: nil, metadata: nil, method_: nil, seed: nil, suffix: nil, validation_file: nil, request_options: {})
  20. #
  21. # @param model [String, Symbol, OpenAI::Models::FineTuning::JobCreateParams::Model] The name of the model to fine-tune. You can select one of the
  22. #
  23. # @param training_file [String] The ID of an uploaded file that contains training data.
  24. #
  25. # @param hyperparameters [OpenAI::Models::FineTuning::JobCreateParams::Hyperparameters] The hyperparameters used for the fine-tuning job.
  26. #
  27. # @param integrations [Array<OpenAI::Models::FineTuning::JobCreateParams::Integration>, nil] A list of integrations to enable for your fine-tuning job.
  28. #
  29. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  30. #
  31. # @param method_ [OpenAI::Models::FineTuning::JobCreateParams::Method] The method used for fine-tuning.
  32. #
  33. # @param seed [Integer, nil] The seed controls the reproducibility of the job. Passing in the same seed and j
  34. #
  35. # @param suffix [String, nil] A string of up to 64 characters that will be added to your fine-tuned model name
  36. #
  37. # @param validation_file [String, nil] The ID of an uploaded file that contains validation data.
  38. #
  39. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  40. #
  41. # @return [OpenAI::Models::FineTuning::FineTuningJob]
  42. #
  43. # @see OpenAI::Models::FineTuning::JobCreateParams
  44. 1 def create(params)
  45. parsed, options = OpenAI::FineTuning::JobCreateParams.dump_request(params)
  46. @client.request(
  47. method: :post,
  48. path: "fine_tuning/jobs",
  49. body: parsed,
  50. model: OpenAI::FineTuning::FineTuningJob,
  51. options: options
  52. )
  53. end
  54. # Some parameter documentations has been truncated, see
  55. # {OpenAI::Models::FineTuning::JobRetrieveParams} for more details.
  56. #
  57. # Get info about a fine-tuning job.
  58. #
  59. # [Learn more about fine-tuning](https://platform.openai.com/docs/guides/model-optimization)
  60. #
  61. # @overload retrieve(fine_tuning_job_id, request_options: {})
  62. #
  63. # @param fine_tuning_job_id [String] The ID of the fine-tuning job.
  64. #
  65. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  66. #
  67. # @return [OpenAI::Models::FineTuning::FineTuningJob]
  68. #
  69. # @see OpenAI::Models::FineTuning::JobRetrieveParams
  70. 1 def retrieve(fine_tuning_job_id, params = {})
  71. @client.request(
  72. method: :get,
  73. path: ["fine_tuning/jobs/%1$s", fine_tuning_job_id],
  74. model: OpenAI::FineTuning::FineTuningJob,
  75. options: params[:request_options]
  76. )
  77. end
  78. # Some parameter documentations has been truncated, see
  79. # {OpenAI::Models::FineTuning::JobListParams} for more details.
  80. #
  81. # List your organization's fine-tuning jobs
  82. #
  83. # @overload list(after: nil, limit: nil, metadata: nil, request_options: {})
  84. #
  85. # @param after [String] Identifier for the last job from the previous pagination request.
  86. #
  87. # @param limit [Integer] Number of fine-tuning jobs to retrieve.
  88. #
  89. # @param metadata [Hash{Symbol=>String}, nil] Optional metadata filter. To filter, use the syntax `metadata[k]=v`. Alternative
  90. #
  91. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  92. #
  93. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::FineTuning::FineTuningJob>]
  94. #
  95. # @see OpenAI::Models::FineTuning::JobListParams
  96. 1 def list(params = {})
  97. parsed, options = OpenAI::FineTuning::JobListParams.dump_request(params)
  98. @client.request(
  99. method: :get,
  100. path: "fine_tuning/jobs",
  101. query: parsed,
  102. page: OpenAI::Internal::CursorPage,
  103. model: OpenAI::FineTuning::FineTuningJob,
  104. options: options
  105. )
  106. end
  107. # Some parameter documentations has been truncated, see
  108. # {OpenAI::Models::FineTuning::JobCancelParams} for more details.
  109. #
  110. # Immediately cancel a fine-tune job.
  111. #
  112. # @overload cancel(fine_tuning_job_id, request_options: {})
  113. #
  114. # @param fine_tuning_job_id [String] The ID of the fine-tuning job to cancel.
  115. #
  116. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  117. #
  118. # @return [OpenAI::Models::FineTuning::FineTuningJob]
  119. #
  120. # @see OpenAI::Models::FineTuning::JobCancelParams
  121. 1 def cancel(fine_tuning_job_id, params = {})
  122. @client.request(
  123. method: :post,
  124. path: ["fine_tuning/jobs/%1$s/cancel", fine_tuning_job_id],
  125. model: OpenAI::FineTuning::FineTuningJob,
  126. options: params[:request_options]
  127. )
  128. end
  129. # Some parameter documentations has been truncated, see
  130. # {OpenAI::Models::FineTuning::JobListEventsParams} for more details.
  131. #
  132. # Get status updates for a fine-tuning job.
  133. #
  134. # @overload list_events(fine_tuning_job_id, after: nil, limit: nil, request_options: {})
  135. #
  136. # @param fine_tuning_job_id [String] The ID of the fine-tuning job to get events for.
  137. #
  138. # @param after [String] Identifier for the last event from the previous pagination request.
  139. #
  140. # @param limit [Integer] Number of events to retrieve.
  141. #
  142. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  143. #
  144. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::FineTuning::FineTuningJobEvent>]
  145. #
  146. # @see OpenAI::Models::FineTuning::JobListEventsParams
  147. 1 def list_events(fine_tuning_job_id, params = {})
  148. parsed, options = OpenAI::FineTuning::JobListEventsParams.dump_request(params)
  149. @client.request(
  150. method: :get,
  151. path: ["fine_tuning/jobs/%1$s/events", fine_tuning_job_id],
  152. query: parsed,
  153. page: OpenAI::Internal::CursorPage,
  154. model: OpenAI::FineTuning::FineTuningJobEvent,
  155. options: options
  156. )
  157. end
  158. # Some parameter documentations has been truncated, see
  159. # {OpenAI::Models::FineTuning::JobPauseParams} for more details.
  160. #
  161. # Pause a fine-tune job.
  162. #
  163. # @overload pause(fine_tuning_job_id, request_options: {})
  164. #
  165. # @param fine_tuning_job_id [String] The ID of the fine-tuning job to pause.
  166. #
  167. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  168. #
  169. # @return [OpenAI::Models::FineTuning::FineTuningJob]
  170. #
  171. # @see OpenAI::Models::FineTuning::JobPauseParams
  172. 1 def pause(fine_tuning_job_id, params = {})
  173. @client.request(
  174. method: :post,
  175. path: ["fine_tuning/jobs/%1$s/pause", fine_tuning_job_id],
  176. model: OpenAI::FineTuning::FineTuningJob,
  177. options: params[:request_options]
  178. )
  179. end
  180. # Some parameter documentations has been truncated, see
  181. # {OpenAI::Models::FineTuning::JobResumeParams} for more details.
  182. #
  183. # Resume a fine-tune job.
  184. #
  185. # @overload resume(fine_tuning_job_id, request_options: {})
  186. #
  187. # @param fine_tuning_job_id [String] The ID of the fine-tuning job to resume.
  188. #
  189. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  190. #
  191. # @return [OpenAI::Models::FineTuning::FineTuningJob]
  192. #
  193. # @see OpenAI::Models::FineTuning::JobResumeParams
  194. 1 def resume(fine_tuning_job_id, params = {})
  195. @client.request(
  196. method: :post,
  197. path: ["fine_tuning/jobs/%1$s/resume", fine_tuning_job_id],
  198. model: OpenAI::FineTuning::FineTuningJob,
  199. options: params[:request_options]
  200. )
  201. end
  202. # @api private
  203. #
  204. # @param client [OpenAI::Client]
  205. 1 def initialize(client:)
  206. 2 @client = client
  207. 2 @checkpoints = OpenAI::Resources::FineTuning::Jobs::Checkpoints.new(client: client)
  208. end
  209. end
  210. end
  211. end
  212. end

openai-ruby/lib/openai/resources/fine_tuning/jobs/checkpoints.rb

80.0% lines covered

100.0% branches covered

10 relevant lines. 8 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class FineTuning
  5. 1 class Jobs
  6. 1 class Checkpoints
  7. # Some parameter documentations has been truncated, see
  8. # {OpenAI::Models::FineTuning::Jobs::CheckpointListParams} for more details.
  9. #
  10. # List checkpoints for a fine-tuning job.
  11. #
  12. # @overload list(fine_tuning_job_id, after: nil, limit: nil, request_options: {})
  13. #
  14. # @param fine_tuning_job_id [String] The ID of the fine-tuning job to get checkpoints for.
  15. #
  16. # @param after [String] Identifier for the last checkpoint ID from the previous pagination request.
  17. #
  18. # @param limit [Integer] Number of checkpoints to retrieve.
  19. #
  20. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  21. #
  22. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::FineTuning::Jobs::FineTuningJobCheckpoint>]
  23. #
  24. # @see OpenAI::Models::FineTuning::Jobs::CheckpointListParams
  25. 1 def list(fine_tuning_job_id, params = {})
  26. parsed, options = OpenAI::FineTuning::Jobs::CheckpointListParams.dump_request(params)
  27. @client.request(
  28. method: :get,
  29. path: ["fine_tuning/jobs/%1$s/checkpoints", fine_tuning_job_id],
  30. query: parsed,
  31. page: OpenAI::Internal::CursorPage,
  32. model: OpenAI::FineTuning::Jobs::FineTuningJobCheckpoint,
  33. options: options
  34. )
  35. end
  36. # @api private
  37. #
  38. # @param client [OpenAI::Client]
  39. 1 def initialize(client:)
  40. 2 @client = client
  41. end
  42. end
  43. end
  44. end
  45. end
  46. end

openai-ruby/lib/openai/resources/fine_tuning/methods.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class FineTuning
  5. 1 class Methods
  6. # @api private
  7. #
  8. # @param client [OpenAI::Client]
  9. 1 def initialize(client:)
  10. 2 @client = client
  11. end
  12. end
  13. end
  14. end
  15. end

openai-ruby/lib/openai/resources/graders.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Graders
  5. # @return [OpenAI::Resources::Graders::GraderModels]
  6. 1 attr_reader :grader_models
  7. # @api private
  8. #
  9. # @param client [OpenAI::Client]
  10. 1 def initialize(client:)
  11. 2 @client = client
  12. 2 @grader_models = OpenAI::Resources::Graders::GraderModels.new(client: client)
  13. end
  14. end
  15. end
  16. end

openai-ruby/lib/openai/resources/graders/grader_models.rb

100.0% lines covered

100.0% branches covered

6 relevant lines. 6 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Graders
  5. 1 class GraderModels
  6. # @api private
  7. #
  8. # @param client [OpenAI::Client]
  9. 1 def initialize(client:)
  10. 2 @client = client
  11. end
  12. end
  13. end
  14. end
  15. end

openai-ruby/lib/openai/resources/images.rb

29.41% lines covered

0.0% branches covered

34 relevant lines. 10 lines covered and 24 lines missed.
8 total branches, 0 branches covered and 8 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Images
  5. # Some parameter documentations has been truncated, see
  6. # {OpenAI::Models::ImageCreateVariationParams} for more details.
  7. #
  8. # Creates a variation of a given image. This endpoint only supports `dall-e-2`.
  9. #
  10. # @overload create_variation(image:, model: nil, n: nil, response_format: nil, size: nil, user: nil, request_options: {})
  11. #
  12. # @param image [Pathname, StringIO, IO, String, OpenAI::FilePart] The image to use as the basis for the variation(s). Must be a valid PNG file, le
  13. #
  14. # @param model [String, Symbol, OpenAI::Models::ImageModel, nil] The model to use for image generation. Only `dall-e-2` is supported at this time
  15. #
  16. # @param n [Integer, nil] The number of images to generate. Must be between 1 and 10.
  17. #
  18. # @param response_format [Symbol, OpenAI::Models::ImageCreateVariationParams::ResponseFormat, nil] The format in which the generated images are returned. Must be one of `url` or `
  19. #
  20. # @param size [Symbol, OpenAI::Models::ImageCreateVariationParams::Size, nil] The size of the generated images. Must be one of `256x256`, `512x512`, or `1024x
  21. #
  22. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  23. #
  24. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  25. #
  26. # @return [OpenAI::Models::ImagesResponse]
  27. #
  28. # @see OpenAI::Models::ImageCreateVariationParams
  29. 1 def create_variation(params)
  30. parsed, options = OpenAI::ImageCreateVariationParams.dump_request(params)
  31. @client.request(
  32. method: :post,
  33. path: "images/variations",
  34. headers: {"content-type" => "multipart/form-data"},
  35. body: parsed,
  36. model: OpenAI::ImagesResponse,
  37. options: options
  38. )
  39. end
  40. # See {OpenAI::Resources::Images#edit_stream_raw} for streaming counterpart.
  41. #
  42. # Some parameter documentations has been truncated, see
  43. # {OpenAI::Models::ImageEditParams} for more details.
  44. #
  45. # Creates an edited or extended image given one or more source images and a
  46. # prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`.
  47. #
  48. # @overload edit(image:, prompt:, background: nil, input_fidelity: nil, mask: nil, model: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, user: nil, request_options: {})
  49. #
  50. # @param image [Pathname, StringIO, IO, String, OpenAI::FilePart, Array<Pathname, StringIO, IO, String, OpenAI::FilePart>] The image(s) to edit. Must be a supported image file or an array of images.
  51. #
  52. # @param prompt [String] A text description of the desired image(s). The maximum length is 1000 character
  53. #
  54. # @param background [Symbol, OpenAI::Models::ImageEditParams::Background, nil] Allows to set transparency for the background of the generated image(s).
  55. #
  56. # @param input_fidelity [Symbol, OpenAI::Models::ImageEditParams::InputFidelity, nil] Control how much effort the model will exert to match the style and features,
  57. #
  58. # @param mask [Pathname, StringIO, IO, String, OpenAI::FilePart] An additional image whose fully transparent areas (e.g. where alpha is zero) ind
  59. #
  60. # @param model [String, Symbol, OpenAI::Models::ImageModel, nil] The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are sup
  61. #
  62. # @param n [Integer, nil] The number of images to generate. Must be between 1 and 10.
  63. #
  64. # @param output_compression [Integer, nil] The compression level (0-100%) for the generated images. This parameter
  65. #
  66. # @param output_format [Symbol, OpenAI::Models::ImageEditParams::OutputFormat, nil] The format in which the generated images are returned. This parameter is
  67. #
  68. # @param partial_images [Integer, nil] The number of partial images to generate. This parameter is used for
  69. #
  70. # @param quality [Symbol, OpenAI::Models::ImageEditParams::Quality, nil] The quality of the image that will be generated. `high`, `medium` and `low` are
  71. #
  72. # @param response_format [Symbol, OpenAI::Models::ImageEditParams::ResponseFormat, nil] The format in which the generated images are returned. Must be one of `url` or `
  73. #
  74. # @param size [Symbol, OpenAI::Models::ImageEditParams::Size, nil] The size of the generated images. Must be one of `1024x1024`, `1536x1024` (lands
  75. #
  76. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  77. #
  78. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  79. #
  80. # @return [OpenAI::Models::ImagesResponse]
  81. #
  82. # @see OpenAI::Models::ImageEditParams
  83. 1 def edit(params)
  84. parsed, options = OpenAI::ImageEditParams.dump_request(params)
  85. then: 0 else: 0 if parsed[:stream]
  86. message = "Please use `#edit_stream_raw` for the streaming use case."
  87. raise ArgumentError.new(message)
  88. end
  89. @client.request(
  90. method: :post,
  91. path: "images/edits",
  92. headers: {"content-type" => "multipart/form-data"},
  93. body: parsed,
  94. model: OpenAI::ImagesResponse,
  95. options: options
  96. )
  97. end
  98. # See {OpenAI::Resources::Images#edit} for non-streaming counterpart.
  99. #
  100. # Some parameter documentations has been truncated, see
  101. # {OpenAI::Models::ImageEditParams} for more details.
  102. #
  103. # Creates an edited or extended image given one or more source images and a
  104. # prompt. This endpoint only supports `gpt-image-1` and `dall-e-2`.
  105. #
  106. # @overload edit_stream_raw(image:, prompt:, background: nil, input_fidelity: nil, mask: nil, model: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, user: nil, request_options: {})
  107. #
  108. # @param image [Pathname, StringIO, IO, String, OpenAI::FilePart, Array<Pathname, StringIO, IO, String, OpenAI::FilePart>] The image(s) to edit. Must be a supported image file or an array of images.
  109. #
  110. # @param prompt [String] A text description of the desired image(s). The maximum length is 1000 character
  111. #
  112. # @param background [Symbol, OpenAI::Models::ImageEditParams::Background, nil] Allows to set transparency for the background of the generated image(s).
  113. #
  114. # @param input_fidelity [Symbol, OpenAI::Models::ImageEditParams::InputFidelity, nil] Control how much effort the model will exert to match the style and features,
  115. #
  116. # @param mask [Pathname, StringIO, IO, String, OpenAI::FilePart] An additional image whose fully transparent areas (e.g. where alpha is zero) ind
  117. #
  118. # @param model [String, Symbol, OpenAI::Models::ImageModel, nil] The model to use for image generation. Only `dall-e-2` and `gpt-image-1` are sup
  119. #
  120. # @param n [Integer, nil] The number of images to generate. Must be between 1 and 10.
  121. #
  122. # @param output_compression [Integer, nil] The compression level (0-100%) for the generated images. This parameter
  123. #
  124. # @param output_format [Symbol, OpenAI::Models::ImageEditParams::OutputFormat, nil] The format in which the generated images are returned. This parameter is
  125. #
  126. # @param partial_images [Integer, nil] The number of partial images to generate. This parameter is used for
  127. #
  128. # @param quality [Symbol, OpenAI::Models::ImageEditParams::Quality, nil] The quality of the image that will be generated. `high`, `medium` and `low` are
  129. #
  130. # @param response_format [Symbol, OpenAI::Models::ImageEditParams::ResponseFormat, nil] The format in which the generated images are returned. Must be one of `url` or `
  131. #
  132. # @param size [Symbol, OpenAI::Models::ImageEditParams::Size, nil] The size of the generated images. Must be one of `1024x1024`, `1536x1024` (lands
  133. #
  134. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  135. #
  136. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  137. #
  138. # @return [OpenAI::Internal::Stream<OpenAI::Models::ImageEditPartialImageEvent, OpenAI::Models::ImageEditCompletedEvent>]
  139. #
  140. # @see OpenAI::Models::ImageEditParams
  141. 1 def edit_stream_raw(params)
  142. parsed, options = OpenAI::ImageEditParams.dump_request(params)
  143. else: 0 then: 0 unless parsed.fetch(:stream, true)
  144. message = "Please use `#edit` for the non-streaming use case."
  145. raise ArgumentError.new(message)
  146. end
  147. parsed.store(:stream, true)
  148. @client.request(
  149. method: :post,
  150. path: "images/edits",
  151. headers: {"content-type" => "multipart/form-data", "accept" => "text/event-stream"},
  152. body: parsed,
  153. stream: OpenAI::Internal::Stream,
  154. model: OpenAI::ImageEditStreamEvent,
  155. options: options
  156. )
  157. end
  158. # See {OpenAI::Resources::Images#generate_stream_raw} for streaming counterpart.
  159. #
  160. # Some parameter documentations has been truncated, see
  161. # {OpenAI::Models::ImageGenerateParams} for more details.
  162. #
  163. # Creates an image given a prompt.
  164. # [Learn more](https://platform.openai.com/docs/guides/images).
  165. #
  166. # @overload generate(prompt:, background: nil, model: nil, moderation: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, style: nil, user: nil, request_options: {})
  167. #
  168. # @param prompt [String] A text description of the desired image(s). The maximum length is 32000 characte
  169. #
  170. # @param background [Symbol, OpenAI::Models::ImageGenerateParams::Background, nil] Allows to set transparency for the background of the generated image(s).
  171. #
  172. # @param model [String, Symbol, OpenAI::Models::ImageModel, nil] The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or `gpt-im
  173. #
  174. # @param moderation [Symbol, OpenAI::Models::ImageGenerateParams::Moderation, nil] Control the content-moderation level for images generated by `gpt-image-1`. Must
  175. #
  176. # @param n [Integer, nil] The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
  177. #
  178. # @param output_compression [Integer, nil] The compression level (0-100%) for the generated images. This parameter is only
  179. #
  180. # @param output_format [Symbol, OpenAI::Models::ImageGenerateParams::OutputFormat, nil] The format in which the generated images are returned. This parameter is only su
  181. #
  182. # @param partial_images [Integer, nil] The number of partial images to generate. This parameter is used for
  183. #
  184. # @param quality [Symbol, OpenAI::Models::ImageGenerateParams::Quality, nil] The quality of the image that will be generated.
  185. #
  186. # @param response_format [Symbol, OpenAI::Models::ImageGenerateParams::ResponseFormat, nil] The format in which generated images with `dall-e-2` and `dall-e-3` are returned
  187. #
  188. # @param size [Symbol, OpenAI::Models::ImageGenerateParams::Size, nil] The size of the generated images. Must be one of `1024x1024`, `1536x1024` (lands
  189. #
  190. # @param style [Symbol, OpenAI::Models::ImageGenerateParams::Style, nil] The style of the generated images. This parameter is only supported for `dall-e-
  191. #
  192. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  193. #
  194. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  195. #
  196. # @return [OpenAI::Models::ImagesResponse]
  197. #
  198. # @see OpenAI::Models::ImageGenerateParams
  199. 1 def generate(params)
  200. parsed, options = OpenAI::ImageGenerateParams.dump_request(params)
  201. then: 0 else: 0 if parsed[:stream]
  202. message = "Please use `#generate_stream_raw` for the streaming use case."
  203. raise ArgumentError.new(message)
  204. end
  205. @client.request(
  206. method: :post,
  207. path: "images/generations",
  208. body: parsed,
  209. model: OpenAI::ImagesResponse,
  210. options: options
  211. )
  212. end
  213. # See {OpenAI::Resources::Images#generate} for non-streaming counterpart.
  214. #
  215. # Some parameter documentations has been truncated, see
  216. # {OpenAI::Models::ImageGenerateParams} for more details.
  217. #
  218. # Creates an image given a prompt.
  219. # [Learn more](https://platform.openai.com/docs/guides/images).
  220. #
  221. # @overload generate_stream_raw(prompt:, background: nil, model: nil, moderation: nil, n: nil, output_compression: nil, output_format: nil, partial_images: nil, quality: nil, response_format: nil, size: nil, style: nil, user: nil, request_options: {})
  222. #
  223. # @param prompt [String] A text description of the desired image(s). The maximum length is 32000 characte
  224. #
  225. # @param background [Symbol, OpenAI::Models::ImageGenerateParams::Background, nil] Allows to set transparency for the background of the generated image(s).
  226. #
  227. # @param model [String, Symbol, OpenAI::Models::ImageModel, nil] The model to use for image generation. One of `dall-e-2`, `dall-e-3`, or `gpt-im
  228. #
  229. # @param moderation [Symbol, OpenAI::Models::ImageGenerateParams::Moderation, nil] Control the content-moderation level for images generated by `gpt-image-1`. Must
  230. #
  231. # @param n [Integer, nil] The number of images to generate. Must be between 1 and 10. For `dall-e-3`, only
  232. #
  233. # @param output_compression [Integer, nil] The compression level (0-100%) for the generated images. This parameter is only
  234. #
  235. # @param output_format [Symbol, OpenAI::Models::ImageGenerateParams::OutputFormat, nil] The format in which the generated images are returned. This parameter is only su
  236. #
  237. # @param partial_images [Integer, nil] The number of partial images to generate. This parameter is used for
  238. #
  239. # @param quality [Symbol, OpenAI::Models::ImageGenerateParams::Quality, nil] The quality of the image that will be generated.
  240. #
  241. # @param response_format [Symbol, OpenAI::Models::ImageGenerateParams::ResponseFormat, nil] The format in which generated images with `dall-e-2` and `dall-e-3` are returned
  242. #
  243. # @param size [Symbol, OpenAI::Models::ImageGenerateParams::Size, nil] The size of the generated images. Must be one of `1024x1024`, `1536x1024` (lands
  244. #
  245. # @param style [Symbol, OpenAI::Models::ImageGenerateParams::Style, nil] The style of the generated images. This parameter is only supported for `dall-e-
  246. #
  247. # @param user [String] A unique identifier representing your end-user, which can help OpenAI to monitor
  248. #
  249. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  250. #
  251. # @return [OpenAI::Internal::Stream<OpenAI::Models::ImageGenPartialImageEvent, OpenAI::Models::ImageGenCompletedEvent>]
  252. #
  253. # @see OpenAI::Models::ImageGenerateParams
  254. 1 def generate_stream_raw(params)
  255. parsed, options = OpenAI::ImageGenerateParams.dump_request(params)
  256. else: 0 then: 0 unless parsed.fetch(:stream, true)
  257. message = "Please use `#generate` for the non-streaming use case."
  258. raise ArgumentError.new(message)
  259. end
  260. parsed.store(:stream, true)
  261. @client.request(
  262. method: :post,
  263. path: "images/generations",
  264. headers: {"accept" => "text/event-stream"},
  265. body: parsed,
  266. stream: OpenAI::Internal::Stream,
  267. model: OpenAI::ImageGenStreamEvent,
  268. options: options
  269. )
  270. end
  271. # @api private
  272. #
  273. # @param client [OpenAI::Client]
  274. 1 def initialize(client:)
  275. 2 @client = client
  276. end
  277. end
  278. end
  279. end

openai-ruby/lib/openai/resources/models.rb

72.73% lines covered

100.0% branches covered

11 relevant lines. 8 lines covered and 3 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Models
  5. # Retrieves a model instance, providing basic information about the model such as
  6. # the owner and permissioning.
  7. #
  8. # @overload retrieve(model, request_options: {})
  9. #
  10. # @param model [String] The ID of the model to use for this request
  11. #
  12. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  13. #
  14. # @return [OpenAI::Models::Model]
  15. #
  16. # @see OpenAI::Models::ModelRetrieveParams
  17. 1 def retrieve(model, params = {})
  18. @client.request(
  19. method: :get,
  20. path: ["models/%1$s", model],
  21. model: OpenAI::Model,
  22. options: params[:request_options]
  23. )
  24. end
  25. # Lists the currently available models, and provides basic information about each
  26. # one such as the owner and availability.
  27. #
  28. # @overload list(request_options: {})
  29. #
  30. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  31. #
  32. # @return [OpenAI::Internal::Page<OpenAI::Models::Model>]
  33. #
  34. # @see OpenAI::Models::ModelListParams
  35. 1 def list(params = {})
  36. @client.request(
  37. method: :get,
  38. path: "models",
  39. page: OpenAI::Internal::Page,
  40. model: OpenAI::Model,
  41. options: params[:request_options]
  42. )
  43. end
  44. # Delete a fine-tuned model. You must have the Owner role in your organization to
  45. # delete a model.
  46. #
  47. # @overload delete(model, request_options: {})
  48. #
  49. # @param model [String] The model to delete
  50. #
  51. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  52. #
  53. # @return [OpenAI::Models::ModelDeleted]
  54. #
  55. # @see OpenAI::Models::ModelDeleteParams
  56. 1 def delete(model, params = {})
  57. @client.request(
  58. method: :delete,
  59. path: ["models/%1$s", model],
  60. model: OpenAI::ModelDeleted,
  61. options: params[:request_options]
  62. )
  63. end
  64. # @api private
  65. #
  66. # @param client [OpenAI::Client]
  67. 1 def initialize(client:)
  68. 2 @client = client
  69. end
  70. end
  71. end
  72. end

openai-ruby/lib/openai/resources/moderations.rb

75.0% lines covered

100.0% branches covered

8 relevant lines. 6 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Moderations
  5. # Some parameter documentations has been truncated, see
  6. # {OpenAI::Models::ModerationCreateParams} for more details.
  7. #
  8. # Classifies if text and/or image inputs are potentially harmful. Learn more in
  9. # the [moderation guide](https://platform.openai.com/docs/guides/moderation).
  10. #
  11. # @overload create(input:, model: nil, request_options: {})
  12. #
  13. # @param input [String, Array<String>, Array<OpenAI::Models::ModerationImageURLInput, OpenAI::Models::ModerationTextInput>] Input (or inputs) to classify. Can be a single string, an array of strings, or
  14. #
  15. # @param model [String, Symbol, OpenAI::Models::ModerationModel] The content moderation model you would like to use. Learn more in
  16. #
  17. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  18. #
  19. # @return [OpenAI::Models::ModerationCreateResponse]
  20. #
  21. # @see OpenAI::Models::ModerationCreateParams
  22. 1 def create(params)
  23. parsed, options = OpenAI::ModerationCreateParams.dump_request(params)
  24. @client.request(
  25. method: :post,
  26. path: "moderations",
  27. body: parsed,
  28. model: OpenAI::Models::ModerationCreateResponse,
  29. options: options
  30. )
  31. end
  32. # @api private
  33. #
  34. # @param client [OpenAI::Client]
  35. 1 def initialize(client:)
  36. 2 @client = client
  37. end
  38. end
  39. end
  40. end

openai-ruby/lib/openai/resources/responses.rb

25.0% lines covered

5.0% branches covered

108 relevant lines. 27 lines covered and 81 lines missed.
40 total branches, 2 branches covered and 38 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Responses
  5. # @return [OpenAI::Resources::Responses::InputItems]
  6. 1 attr_reader :input_items
  7. # See {OpenAI::Resources::Responses#stream_raw} for streaming counterpart.
  8. #
  9. # Some parameter documentations has been truncated, see
  10. # {OpenAI::Models::Responses::ResponseCreateParams} for more details.
  11. #
  12. # Creates a model response. Provide
  13. # [text](https://platform.openai.com/docs/guides/text) or
  14. # [image](https://platform.openai.com/docs/guides/images) inputs to generate
  15. # [text](https://platform.openai.com/docs/guides/text) or
  16. # [JSON](https://platform.openai.com/docs/guides/structured-outputs) outputs. Have
  17. # the model call your own
  18. # [custom code](https://platform.openai.com/docs/guides/function-calling) or use
  19. # built-in [tools](https://platform.openai.com/docs/guides/tools) like
  20. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  21. # [file search](https://platform.openai.com/docs/guides/tools-file-search) to use
  22. # your own data as input for the model's response.
  23. #
  24. # @overload create(background: nil, include: nil, input: nil, instructions: nil, max_output_tokens: nil, max_tool_calls: nil, metadata: nil, model: nil, parallel_tool_calls: nil, previous_response_id: nil, prompt: nil, prompt_cache_key: nil, reasoning: nil, safety_identifier: nil, service_tier: nil, store: nil, temperature: nil, text: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, truncation: nil, user: nil, request_options: {})
  25. #
  26. # @param background [Boolean, nil] Whether to run the model response in the background.
  27. #
  28. # @param include [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>, nil] Specify additional output data to include in the model response. Currently
  29. #
  30. # @param input [String, Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference>] Text, image, or file inputs to the model, used to generate a response.
  31. #
  32. # @param instructions [String, nil] A system (or developer) message inserted into the model's context.
  33. #
  34. # @param max_output_tokens [Integer, nil] An upper bound for the number of tokens that can be generated for a response, in
  35. #
  36. # @param max_tool_calls [Integer, nil] The maximum number of total calls to built-in tools that can be processed in a r
  37. #
  38. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  39. #
  40. # @param model [String, Symbol, OpenAI::Models::ChatModel, OpenAI::Models::ResponsesModel::ResponsesOnlyModel] Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
  41. #
  42. # @param parallel_tool_calls [Boolean, nil] Whether to allow the model to run tool calls in parallel.
  43. #
  44. # @param previous_response_id [String, nil] The unique ID of the previous response to the model. Use this to
  45. #
  46. # @param prompt [OpenAI::Models::Responses::ResponsePrompt, nil] Reference to a prompt template and its variables.
  47. #
  48. # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi
  49. #
  50. # @param reasoning [OpenAI::Models::Reasoning, nil] **o-series models only**
  51. #
  52. # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi
  53. #
  54. # @param service_tier [Symbol, OpenAI::Models::Responses::ResponseCreateParams::ServiceTier, nil] Specifies the processing type used for serving the request.
  55. #
  56. # @param store [Boolean, nil] Whether to store the generated model response for later retrieval via
  57. #
  58. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  59. #
  60. # @param text [OpenAI::Models::Responses::ResponseTextConfig] Configuration options for a text response from the model. Can be plain
  61. #
  62. # @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp] How the model should select which tool (or tools) to use when generating
  63. #
  64. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  65. #
  66. # @param top_logprobs [Integer, nil] An integer between 0 and 20 specifying the number of most likely tokens to
  67. #
  68. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling,
  69. #
  70. # @param truncation [Symbol, OpenAI::Models::Responses::ResponseCreateParams::Truncation, nil] The truncation strategy to use for the model response.
  71. #
  72. # @param user [String] This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  73. #
  74. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  75. #
  76. # @return [OpenAI::Models::Responses::Response]
  77. #
  78. # @see OpenAI::Models::Responses::ResponseCreateParams
  79. 1 def create(params = {})
  80. 2 parsed, options = OpenAI::Responses::ResponseCreateParams.dump_request(params)
  81. 2 then: 0 else: 2 if parsed[:stream]
  82. message = "Please use `#stream_raw` for the streaming use case."
  83. raise ArgumentError.new(message)
  84. end
  85. 2 model, tool_models = get_structured_output_models(parsed)
  86. 2 unwrap = ->(raw) do
  87. parse_structured_outputs!(raw, model, tool_models)
  88. end
  89. 2 @client.request(
  90. method: :post,
  91. path: "responses",
  92. body: parsed,
  93. unwrap: unwrap,
  94. model: OpenAI::Responses::Response,
  95. options: options
  96. )
  97. end
  98. # See {OpenAI::Resources::Responses#create} for non-streaming counterpart.
  99. #
  100. # Some parameter documentations has been truncated, see
  101. # {OpenAI::Models::Responses::ResponseCreateParams} for more details.
  102. #
  103. # Creates a model response. Provide
  104. # [text](https://platform.openai.com/docs/guides/text) or
  105. # [image](https://platform.openai.com/docs/guides/images) inputs to generate
  106. # [text](https://platform.openai.com/docs/guides/text) or
  107. # [JSON](https://platform.openai.com/docs/guides/structured-outputs) outputs. Have
  108. # the model call your own
  109. # [custom code](https://platform.openai.com/docs/guides/function-calling) or use
  110. # built-in [tools](https://platform.openai.com/docs/guides/tools) like
  111. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  112. # [file search](https://platform.openai.com/docs/guides/tools-file-search) to use
  113. # your own data as input for the model's response.
  114. #
  115. # @overload stream_raw(input:, model:, background: nil, include: nil, instructions: nil, max_output_tokens: nil, metadata: nil, parallel_tool_calls: nil, previous_response_id: nil, prompt: nil, reasoning: nil, service_tier: nil, store: nil, temperature: nil, text: nil, tool_choice: nil, tools: nil, top_p: nil, truncation: nil, user: nil, request_options: {})
  116. #
  117. # @param input [String, Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference>] Text, image, or file inputs to the model, used to generate a response.
  118. #
  119. # @param model [String, Symbol, OpenAI::Models::ChatModel, OpenAI::Models::ResponsesModel::ResponsesOnlyModel] Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
  120. #
  121. # @param background [Boolean, nil] Whether to run the model response in the background.
  122. #
  123. # @param include [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>, nil] Specify additional output data to include in the model response. Currently
  124. #
  125. # @param instructions [String, nil] A system (or developer) message inserted into the model's context.
  126. #
  127. # @param max_output_tokens [Integer, nil] An upper bound for the number of tokens that can be generated for a response, in
  128. #
  129. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  130. #
  131. # @param parallel_tool_calls [Boolean, nil] Whether to allow the model to run tool calls in parallel.
  132. #
  133. # @param previous_response_id [String, nil] The unique ID of the previous response to the model. Use this to resume streams from a given response.
  134. #
  135. # @param prompt [OpenAI::Models::Responses::ResponsePrompt, nil] Reference to a prompt template and its variables.
  136. #
  137. # @param reasoning [OpenAI::Models::Reasoning, nil] **o-series models only**
  138. #
  139. # @param service_tier [Symbol, OpenAI::Models::Responses::ResponseCreateParams::ServiceTier, nil] Specifies the latency tier to use for processing the request. This parameter is
  140. #
  141. # @param store [Boolean, nil] Whether to store the generated model response for later retrieval via
  142. #
  143. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  144. #
  145. # @param text [OpenAI::Models::Responses::ResponseTextConfig] Configuration options for a text response from the model. Can be plain
  146. #
  147. # @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction] How the model should select which tool (or tools) to use when generating
  148. #
  149. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  150. #
  151. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling,
  152. #
  153. # @param truncation [Symbol, OpenAI::Models::Responses::ResponseCreateParams::Truncation, nil] The truncation strategy to use for the model response.
  154. #
  155. # @param user [String] A stable identifier for your end-users.
  156. #
  157. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  158. #
  159. # @return [OpenAI::Helpers::Streaming::ResponseStream]
  160. #
  161. # @see OpenAI::Models::Responses::ResponseCreateParams
  162. 1 def stream(params)
  163. parsed, options = OpenAI::Responses::ResponseCreateParams.dump_request(params)
  164. starting_after, previous_response_id = parsed.values_at(:starting_after, :previous_response_id)
  165. then: 0 else: 0 if starting_after && !previous_response_id
  166. raise ArgumentError, "starting_after can only be used with previous_response_id"
  167. end
  168. model, tool_models = get_structured_output_models(parsed)
  169. unwrap = ->(raw) do
  170. then: 0 else: 0 if raw[:type] == "response.completed" && raw[:response]
  171. parse_structured_outputs!(raw[:response], model, tool_models)
  172. end
  173. raw
  174. end
  175. then: 0 if previous_response_id
  176. retrieve_params = params.slice(:include, :request_options)
  177. raw_stream = retrieve_streaming_internal(
  178. previous_response_id,
  179. params: retrieve_params,
  180. unwrap: unwrap
  181. )
  182. else: 0 else
  183. parsed[:stream] = true
  184. raw_stream = @client.request(
  185. method: :post,
  186. path: "responses",
  187. headers: {"accept" => "text/event-stream"},
  188. body: parsed,
  189. stream: OpenAI::Internal::Stream,
  190. model: OpenAI::Models::Responses::ResponseStreamEvent,
  191. unwrap: unwrap,
  192. options: options
  193. )
  194. end
  195. OpenAI::Streaming::ResponseStream.new(
  196. raw_stream: raw_stream,
  197. text_format: model,
  198. starting_after: starting_after
  199. )
  200. end
  201. # See {OpenAI::Resources::Responses#create} for non-streaming counterpart.
  202. #
  203. # Some parameter documentations has been truncated, see
  204. # {OpenAI::Models::Responses::ResponseCreateParams} for more details.
  205. #
  206. # Creates a model response. Provide
  207. # [text](https://platform.openai.com/docs/guides/text) or
  208. # [image](https://platform.openai.com/docs/guides/images) inputs to generate
  209. # [text](https://platform.openai.com/docs/guides/text) or
  210. # [JSON](https://platform.openai.com/docs/guides/structured-outputs) outputs. Have
  211. # the model call your own
  212. # [custom code](https://platform.openai.com/docs/guides/function-calling) or use
  213. # built-in [tools](https://platform.openai.com/docs/guides/tools) like
  214. # [web search](https://platform.openai.com/docs/guides/tools-web-search) or
  215. # [file search](https://platform.openai.com/docs/guides/tools-file-search) to use
  216. # your own data as input for the model's response.
  217. #
  218. # @overload stream_raw(background: nil, include: nil, input: nil, instructions: nil, max_output_tokens: nil, max_tool_calls: nil, metadata: nil, model: nil, parallel_tool_calls: nil, previous_response_id: nil, prompt: nil, prompt_cache_key: nil, reasoning: nil, safety_identifier: nil, service_tier: nil, store: nil, temperature: nil, text: nil, tool_choice: nil, tools: nil, top_logprobs: nil, top_p: nil, truncation: nil, user: nil, request_options: {})
  219. #
  220. # @param background [Boolean, nil] Whether to run the model response in the background.
  221. #
  222. # @param include [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>, nil] Specify additional output data to include in the model response. Currently
  223. #
  224. # @param input [String, Array<OpenAI::Models::Responses::EasyInputMessage, OpenAI::Models::Responses::ResponseInputItem::Message, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseInputItem::ComputerCallOutput, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCall, OpenAI::Models::Responses::ResponseInputItem::FunctionCallOutput, OpenAI::Models::Responses::ResponseReasoningItem, OpenAI::Models::Responses::ResponseInputItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCall, OpenAI::Models::Responses::ResponseInputItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseInputItem::McpListTools, OpenAI::Models::Responses::ResponseInputItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseInputItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseInputItem::McpCall, OpenAI::Models::Responses::ResponseInputItem::ItemReference>] Text, image, or file inputs to the model, used to generate a response.
  225. #
  226. # @param instructions [String, nil] A system (or developer) message inserted into the model's context.
  227. #
  228. # @param max_output_tokens [Integer, nil] An upper bound for the number of tokens that can be generated for a response, in
  229. #
  230. # @param max_tool_calls [Integer, nil] The maximum number of total calls to built-in tools that can be processed in a r
  231. #
  232. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  233. #
  234. # @param model [String, Symbol, OpenAI::Models::ChatModel, OpenAI::Models::ResponsesModel::ResponsesOnlyModel] Model ID used to generate the response, like `gpt-4o` or `o3`. OpenAI
  235. #
  236. # @param parallel_tool_calls [Boolean, nil] Whether to allow the model to run tool calls in parallel.
  237. #
  238. # @param previous_response_id [String, nil] The unique ID of the previous response to the response to the model. Use this to resume streams from a given response.
  239. #
  240. # @param prompt [OpenAI::Models::Responses::ResponsePrompt, nil] Reference to a prompt template and its variables.
  241. #
  242. # @param prompt_cache_key [String] Used by OpenAI to cache responses for similar requests to optimize your cache hi
  243. #
  244. # @param reasoning [OpenAI::Models::Reasoning, nil] **o-series models only**
  245. #
  246. # @param safety_identifier [String] A stable identifier used to help detect users of your application that may be vi
  247. #
  248. # @param service_tier [Symbol, OpenAI::Models::Responses::ResponseCreateParams::ServiceTier, nil] Specifies the processing type used for serving the request.
  249. #
  250. # @param store [Boolean, nil] Whether to store the generated model response for later retrieval via
  251. #
  252. # @param temperature [Float, nil] What sampling temperature to use, between 0 and 2. Higher values like 0.8 will m
  253. #
  254. # @param text [OpenAI::Models::Responses::ResponseTextConfig] Configuration options for a text response from the model. Can be plain
  255. #
  256. # @param tool_choice [Symbol, OpenAI::Models::Responses::ToolChoiceOptions, OpenAI::Models::Responses::ToolChoiceTypes, OpenAI::Models::Responses::ToolChoiceFunction, OpenAI::Models::Responses::ToolChoiceMcp] How the model should select which tool (or tools) to use when generating
  257. #
  258. # @param tools [Array<OpenAI::Models::Responses::FunctionTool, OpenAI::Models::Responses::FileSearchTool, OpenAI::Models::Responses::ComputerTool, OpenAI::Models::Responses::Tool::Mcp, OpenAI::Models::Responses::Tool::CodeInterpreter, OpenAI::Models::Responses::Tool::ImageGeneration, OpenAI::Models::Responses::Tool::LocalShell, OpenAI::Models::Responses::WebSearchTool>] An array of tools the model may call while generating a response. You
  259. #
  260. # @param top_logprobs [Integer, nil] An integer between 0 and 20 specifying the number of most likely tokens to
  261. #
  262. # @param top_p [Float, nil] An alternative to sampling with temperature, called nucleus sampling,
  263. #
  264. # @param truncation [Symbol, OpenAI::Models::Responses::ResponseCreateParams::Truncation, nil] The truncation strategy to use for the model response.
  265. #
  266. # @param user [String] This field is being replaced by `safety_identifier` and `prompt_cache_key`. Use
  267. #
  268. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  269. #
  270. # @return [OpenAI::Internal::Stream<OpenAI::Models::Responses::ResponseAudioDeltaEvent, OpenAI::Models::Responses::ResponseAudioDoneEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent, OpenAI::Models::Responses::ResponseCompletedEvent, OpenAI::Models::Responses::ResponseContentPartAddedEvent, OpenAI::Models::Responses::ResponseContentPartDoneEvent, OpenAI::Models::Responses::ResponseCreatedEvent, OpenAI::Models::Responses::ResponseErrorEvent, OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseInProgressEvent, OpenAI::Models::Responses::ResponseFailedEvent, OpenAI::Models::Responses::ResponseIncompleteEvent, OpenAI::Models::Responses::ResponseOutputItemAddedEvent, OpenAI::Models::Responses::ResponseOutputItemDoneEvent, OpenAI::Models::Responses::ResponseReasoningSummaryPartAddedEvent, OpenAI::Models::Responses::ResponseReasoningSummaryPartDoneEvent, OpenAI::Models::Responses::ResponseReasoningSummaryTextDeltaEvent, OpenAI::Models::Responses::ResponseReasoningSummaryTextDoneEvent, OpenAI::Models::Responses::ResponseRefusalDeltaEvent, OpenAI::Models::Responses::ResponseRefusalDoneEvent, OpenAI::Models::Responses::ResponseTextDeltaEvent, OpenAI::Models::Responses::ResponseTextDoneEvent, OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseImageGenCallCompletedEvent, OpenAI::Models::Responses::ResponseImageGenCallGeneratingEvent, OpenAI::Models::Responses::ResponseImageGenCallInProgressEvent, OpenAI::Models::Responses::ResponseImageGenCallPartialImageEvent, OpenAI::Models::Responses::ResponseMcpCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseMcpCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseMcpCallCompletedEvent, OpenAI::Models::Responses::ResponseMcpCallFailedEvent, OpenAI::Models::Responses::ResponseMcpCallInProgressEvent, OpenAI::Models::Responses::ResponseMcpListToolsCompletedEvent, OpenAI::Models::Responses::ResponseMcpListToolsFailedEvent, OpenAI::Models::Responses::ResponseMcpListToolsInProgressEvent, OpenAI::Models::Responses::ResponseOutputTextAnnotationAddedEvent, OpenAI::Models::Responses::ResponseQueuedEvent, OpenAI::Models::Responses::ResponseReasoningSummaryDeltaEvent, OpenAI::Models::Responses::ResponseReasoningSummaryDoneEvent>]
  271. #
  272. # @see OpenAI::Models::Responses::ResponseCreateParams
  273. 1 def stream_raw(params = {})
  274. parsed, options = OpenAI::Responses::ResponseCreateParams.dump_request(params)
  275. else: 0 then: 0 unless parsed.fetch(:stream, true)
  276. message = "Please use `#create` for the non-streaming use case."
  277. raise ArgumentError.new(message)
  278. end
  279. parsed.store(:stream, true)
  280. @client.request(
  281. method: :post,
  282. path: "responses",
  283. headers: {"accept" => "text/event-stream"},
  284. body: parsed,
  285. stream: OpenAI::Internal::Stream,
  286. model: OpenAI::Responses::ResponseStreamEvent,
  287. options: options
  288. )
  289. end
  290. # See {OpenAI::Resources::Responses#retrieve_streaming} for streaming counterpart.
  291. #
  292. # Some parameter documentations has been truncated, see
  293. # {OpenAI::Models::Responses::ResponseRetrieveParams} for more details.
  294. #
  295. # Retrieves a model response with the given ID.
  296. #
  297. # @overload retrieve(response_id, include: nil, starting_after: nil, request_options: {})
  298. #
  299. # @param response_id [String] The ID of the response to retrieve.
  300. #
  301. # @param include [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>] Additional fields to include in the response. See the `include`
  302. #
  303. # @param starting_after [Integer] The sequence number of the event after which to start streaming.
  304. #
  305. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  306. #
  307. # @return [OpenAI::Models::Responses::Response]
  308. #
  309. # @see OpenAI::Models::Responses::ResponseRetrieveParams
  310. 1 def retrieve(response_id, params = {})
  311. parsed, options = OpenAI::Responses::ResponseRetrieveParams.dump_request(params)
  312. then: 0 else: 0 if parsed[:stream]
  313. message = "Please use `#retrieve_streaming` for the streaming use case."
  314. raise ArgumentError.new(message)
  315. end
  316. @client.request(
  317. method: :get,
  318. path: ["responses/%1$s", response_id],
  319. query: parsed,
  320. model: OpenAI::Responses::Response,
  321. options: options
  322. )
  323. end
  324. # See {OpenAI::Resources::Responses#retrieve} for non-streaming counterpart.
  325. #
  326. # Some parameter documentations has been truncated, see
  327. # {OpenAI::Models::Responses::ResponseRetrieveParams} for more details.
  328. #
  329. # Retrieves a model response with the given ID.
  330. #
  331. # @overload retrieve_streaming(response_id, include: nil, starting_after: nil, request_options: {})
  332. #
  333. # @param response_id [String] The ID of the response to retrieve.
  334. #
  335. # @param include [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>] Additional fields to include in the response. See the `include`
  336. #
  337. # @param starting_after [Integer] The sequence number of the event after which to start streaming.
  338. #
  339. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  340. #
  341. # @return [OpenAI::Internal::Stream<OpenAI::Models::Responses::ResponseAudioDeltaEvent, OpenAI::Models::Responses::ResponseAudioDoneEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDeltaEvent, OpenAI::Models::Responses::ResponseAudioTranscriptDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDeltaEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCodeDoneEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallCompletedEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInProgressEvent, OpenAI::Models::Responses::ResponseCodeInterpreterCallInterpretingEvent, OpenAI::Models::Responses::ResponseCompletedEvent, OpenAI::Models::Responses::ResponseContentPartAddedEvent, OpenAI::Models::Responses::ResponseContentPartDoneEvent, OpenAI::Models::Responses::ResponseCreatedEvent, OpenAI::Models::Responses::ResponseErrorEvent, OpenAI::Models::Responses::ResponseFileSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseFileSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseFileSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseFunctionCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseInProgressEvent, OpenAI::Models::Responses::ResponseFailedEvent, OpenAI::Models::Responses::ResponseIncompleteEvent, OpenAI::Models::Responses::ResponseOutputItemAddedEvent, OpenAI::Models::Responses::ResponseOutputItemDoneEvent, OpenAI::Models::Responses::ResponseReasoningSummaryPartAddedEvent, OpenAI::Models::Responses::ResponseReasoningSummaryPartDoneEvent, OpenAI::Models::Responses::ResponseReasoningSummaryTextDeltaEvent, OpenAI::Models::Responses::ResponseReasoningSummaryTextDoneEvent, OpenAI::Models::Responses::ResponseRefusalDeltaEvent, OpenAI::Models::Responses::ResponseRefusalDoneEvent, OpenAI::Models::Responses::ResponseTextDeltaEvent, OpenAI::Models::Responses::ResponseTextDoneEvent, OpenAI::Models::Responses::ResponseWebSearchCallCompletedEvent, OpenAI::Models::Responses::ResponseWebSearchCallInProgressEvent, OpenAI::Models::Responses::ResponseWebSearchCallSearchingEvent, OpenAI::Models::Responses::ResponseImageGenCallCompletedEvent, OpenAI::Models::Responses::ResponseImageGenCallGeneratingEvent, OpenAI::Models::Responses::ResponseImageGenCallInProgressEvent, OpenAI::Models::Responses::ResponseImageGenCallPartialImageEvent, OpenAI::Models::Responses::ResponseMcpCallArgumentsDeltaEvent, OpenAI::Models::Responses::ResponseMcpCallArgumentsDoneEvent, OpenAI::Models::Responses::ResponseMcpCallCompletedEvent, OpenAI::Models::Responses::ResponseMcpCallFailedEvent, OpenAI::Models::Responses::ResponseMcpCallInProgressEvent, OpenAI::Models::Responses::ResponseMcpListToolsCompletedEvent, OpenAI::Models::Responses::ResponseMcpListToolsFailedEvent, OpenAI::Models::Responses::ResponseMcpListToolsInProgressEvent, OpenAI::Models::Responses::ResponseOutputTextAnnotationAddedEvent, OpenAI::Models::Responses::ResponseQueuedEvent, OpenAI::Models::Responses::ResponseReasoningSummaryDeltaEvent, OpenAI::Models::Responses::ResponseReasoningSummaryDoneEvent>]
  342. #
  343. # @see OpenAI::Models::Responses::ResponseRetrieveParams
  344. 1 def retrieve_streaming(response_id, params = {})
  345. parsed, options = OpenAI::Responses::ResponseRetrieveParams.dump_request(params)
  346. else: 0 then: 0 unless parsed.fetch(:stream, true)
  347. message = "Please use `#retrieve` for the non-streaming use case."
  348. raise ArgumentError.new(message)
  349. end
  350. parsed.store(:stream, true)
  351. @client.request(
  352. method: :get,
  353. path: ["responses/%1$s", response_id],
  354. query: parsed,
  355. headers: {"accept" => "text/event-stream"},
  356. stream: OpenAI::Internal::Stream,
  357. model: OpenAI::Responses::ResponseStreamEvent,
  358. options: options
  359. )
  360. end
  361. 1 private def retrieve_streaming_internal(response_id, params:, unwrap:)
  362. parsed, options = OpenAI::Responses::ResponseRetrieveParams.dump_request(params)
  363. parsed.store(:stream, true)
  364. @client.request(
  365. method: :get,
  366. path: ["responses/%1$s", response_id],
  367. query: parsed,
  368. headers: {"accept" => "text/event-stream"},
  369. stream: OpenAI::Internal::Stream,
  370. model: OpenAI::Responses::ResponseStreamEvent,
  371. options: options,
  372. unwrap: unwrap
  373. )
  374. end
  375. # Deletes a model response with the given ID.
  376. #
  377. # @overload delete(response_id, request_options: {})
  378. #
  379. # @param response_id [String] The ID of the response to delete.
  380. #
  381. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  382. #
  383. # @return [nil]
  384. #
  385. # @see OpenAI::Models::Responses::ResponseDeleteParams
  386. 1 def delete(response_id, params = {})
  387. @client.request(
  388. method: :delete,
  389. path: ["responses/%1$s", response_id],
  390. model: NilClass,
  391. options: params[:request_options]
  392. )
  393. end
  394. # Cancels a model response with the given ID. Only responses created with the
  395. # `background` parameter set to `true` can be cancelled.
  396. # [Learn more](https://platform.openai.com/docs/guides/background).
  397. #
  398. # @overload cancel(response_id, request_options: {})
  399. #
  400. # @param response_id [String] The ID of the response to cancel.
  401. #
  402. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  403. #
  404. # @return [OpenAI::Models::Responses::Response]
  405. #
  406. # @see OpenAI::Models::Responses::ResponseCancelParams
  407. 1 def cancel(response_id, params = {})
  408. @client.request(
  409. method: :post,
  410. path: ["responses/%1$s/cancel", response_id],
  411. model: OpenAI::Responses::Response,
  412. options: params[:request_options]
  413. )
  414. end
  415. # @api private
  416. #
  417. # @param client [OpenAI::Client]
  418. 1 def initialize(client:)
  419. 2 @client = client
  420. 2 @input_items = OpenAI::Resources::Responses::InputItems.new(client: client)
  421. end
  422. 1 private
  423. # Post-processes raw API responses to parse and coerce structured outputs into typed Ruby objects.
  424. #
  425. # This method enhances the raw API response by parsing JSON content in structured outputs
  426. # (both text outputs and function/tool calls) and converting them to their corresponding
  427. # Ruby types using the JsonSchemaConverter models identified during request preparation.
  428. #
  429. # @param raw [Hash] The raw API response hash that will be mutated with parsed data
  430. # @param model [JsonSchemaConverter|nil] The converter for structured text output, if specified
  431. # @param tool_models [Hash<String, JsonSchemaConverter>] Hash mapping tool names to their converters
  432. # @return [Hash] The mutated raw response with added :parsed fields containing typed Ruby objects
  433. #
  434. # The method performs two main transformations:
  435. # 1. For structured text outputs: Finds output_text content, parses the JSON, and coerces it
  436. # to the model type, adding the result as content[:parsed]
  437. # 2. For function/tool calls: Looks up the tool's converter by name, parses the arguments JSON,
  438. # and coerces it to the appropriate type, adding the result as output[:parsed]
  439. 1 def parse_structured_outputs!(raw, model, tool_models)
  440. then: 0 else: 0 if model.is_a?(OpenAI::StructuredOutput::JsonSchemaConverter)
  441. then: 0 else: 0 then: 0 else: 0 raw[:output]
  442. &.flat_map do |output|
  443. else: 0 then: 0 next [] unless output[:type] == "message"
  444. output[:content].to_a
  445. end
  446. &.each do |content|
  447. else: 0 then: 0 next unless content[:type] == "output_text"
  448. begin
  449. parsed = JSON.parse(content.fetch(:text), symbolize_names: true)
  450. rescue JSON::ParserError => e
  451. parsed = e
  452. end
  453. coerced = OpenAI::Internal::Type::Converter.coerce(model, parsed)
  454. content.store(:parsed, coerced)
  455. end
  456. end
  457. then: 0 else: 0 raw[:output]&.each do |output|
  458. else: 0 then: 0 next unless output[:type] == "function_call"
  459. then: 0 else: 0 next if (model = tool_models[output.fetch(:name)]).nil?
  460. begin
  461. parsed = JSON.parse(output.fetch(:arguments), symbolize_names: true)
  462. rescue JSON::ParserError => e
  463. parsed = e
  464. end
  465. coerced = OpenAI::Internal::Type::Converter.coerce(model, parsed)
  466. output.store(:parsed, coerced)
  467. end
  468. raw
  469. end
  470. # Extracts structured output models from request parameters and converts them to JSON Schema format.
  471. #
  472. # This method processes the parsed request parameters to identify any JsonSchemaConverter instances
  473. # that define expected output schemas. It transforms these Ruby schema definitions into the JSON
  474. # Schema format required by the OpenAI API, enabling type-safe structured outputs.
  475. #
  476. # @param parsed [Hash] The parsed request parameters that may contain structured output definitions
  477. # @return [Array<(JsonSchemaConverter|nil, Hash)>] A tuple containing:
  478. # - model: The JsonSchemaConverter for structured text output (or nil if not specified)
  479. # - tool_models: Hash mapping tool names to their JsonSchemaConverter models
  480. #
  481. # The method handles multiple ways structured outputs can be specified:
  482. # - Direct text format: { text: JsonSchemaConverter }
  483. # - Nested text format: { text: { format: JsonSchemaConverter } }
  484. # - Deep nested format: { text: { format: { type: :json_schema, schema: JsonSchemaConverter } } }
  485. # - Tool parameters: { tools: [JsonSchemaConverter, ...] } or tools with parameters as converters
  486. 1 def get_structured_output_models(parsed)
  487. 2 model = nil
  488. 2 tool_models = {}
  489. case parsed
  490. 2 in: 0 in {text: OpenAI::StructuredOutput::JsonSchemaConverter => model}
  491. parsed.update(
  492. text: {
  493. format: {
  494. type: :json_schema,
  495. strict: true,
  496. name: model.name.split("::").last,
  497. schema: model.to_json_schema
  498. }
  499. }
  500. )
  501. in: 0 in {text: {format: OpenAI::StructuredOutput::JsonSchemaConverter => model}}
  502. parsed.fetch(:text).update(
  503. format: {
  504. type: :json_schema,
  505. strict: true,
  506. name: model.name.split("::").last,
  507. schema: model.to_json_schema
  508. }
  509. )
  510. in {text: {format: {type: :json_schema,
  511. in: 0 schema: OpenAI::StructuredOutput::JsonSchemaConverter => model}}}
  512. parsed.dig(:text, :format).store(:schema, model.to_json_schema)
  513. in {tools: Array => tools}
  514. in: 0 # rubocop:disable Metrics/BlockLength
  515. mapped = tools.map do |tool|
  516. case tool
  517. in: 0 in OpenAI::StructuredOutput::JsonSchemaConverter
  518. name = tool.name.split("::").last
  519. tool_models.store(name, tool)
  520. {
  521. type: :function,
  522. strict: true,
  523. name: name,
  524. parameters: tool.to_json_schema
  525. }
  526. in: 0 in {type: :function, parameters: OpenAI::StructuredOutput::JsonSchemaConverter => params}
  527. func = tool.fetch(:function)
  528. name = func[:name] ||= params.name.split("::").last
  529. tool_models.store(name, params)
  530. func.update(parameters: params.to_json_schema)
  531. tool
  532. in: 0 in {type: _, function: {parameters: OpenAI::StructuredOutput::JsonSchemaConverter => params, **}}
  533. name = tool[:function][:name] || params.name.split("::").last
  534. tool_models.store(name, params)
  535. tool[:function][:parameters] = params.to_json_schema
  536. tool
  537. in: 0 in {type: _, function: Hash => func} if func[:parameters].is_a?(Class) && func[:parameters] < OpenAI::Internal::Type::BaseModel
  538. params = func[:parameters]
  539. name = func[:name] || params.name.split("::").last
  540. tool_models.store(name, params)
  541. func[:parameters] = params.to_json_schema
  542. tool
  543. else: 0 else
  544. tool
  545. end
  546. end
  547. # rubocop:enable Metrics/BlockLength
  548. else: 2 tools.replace(mapped)
  549. else
  550. end
  551. 2 [model, tool_models]
  552. end
  553. end
  554. end
  555. end

openai-ruby/lib/openai/resources/responses/input_items.rb

77.78% lines covered

100.0% branches covered

9 relevant lines. 7 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Responses
  5. 1 class InputItems
  6. # Some parameter documentations has been truncated, see
  7. # {OpenAI::Models::Responses::InputItemListParams} for more details.
  8. #
  9. # Returns a list of input items for a given response.
  10. #
  11. # @overload list(response_id, after: nil, before: nil, include: nil, limit: nil, order: nil, request_options: {})
  12. #
  13. # @param response_id [String] The ID of the response to retrieve input items for.
  14. #
  15. # @param after [String] An item ID to list items after, used in pagination.
  16. #
  17. # @param before [String] An item ID to list items before, used in pagination.
  18. #
  19. # @param include [Array<Symbol, OpenAI::Models::Responses::ResponseIncludable>] Additional fields to include in the response. See the `include`
  20. #
  21. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between
  22. #
  23. # @param order [Symbol, OpenAI::Models::Responses::InputItemListParams::Order] The order to return the input items in. Default is `desc`.
  24. #
  25. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  26. #
  27. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::Responses::ResponseInputMessageItem, OpenAI::Models::Responses::ResponseOutputMessage, OpenAI::Models::Responses::ResponseFileSearchToolCall, OpenAI::Models::Responses::ResponseComputerToolCall, OpenAI::Models::Responses::ResponseComputerToolCallOutputItem, OpenAI::Models::Responses::ResponseFunctionWebSearch, OpenAI::Models::Responses::ResponseFunctionToolCallItem, OpenAI::Models::Responses::ResponseFunctionToolCallOutputItem, OpenAI::Models::Responses::ResponseItem::ImageGenerationCall, OpenAI::Models::Responses::ResponseCodeInterpreterToolCall, OpenAI::Models::Responses::ResponseItem::LocalShellCall, OpenAI::Models::Responses::ResponseItem::LocalShellCallOutput, OpenAI::Models::Responses::ResponseItem::McpListTools, OpenAI::Models::Responses::ResponseItem::McpApprovalRequest, OpenAI::Models::Responses::ResponseItem::McpApprovalResponse, OpenAI::Models::Responses::ResponseItem::McpCall>]
  28. #
  29. # @see OpenAI::Models::Responses::InputItemListParams
  30. 1 def list(response_id, params = {})
  31. parsed, options = OpenAI::Responses::InputItemListParams.dump_request(params)
  32. @client.request(
  33. method: :get,
  34. path: ["responses/%1$s/input_items", response_id],
  35. query: parsed,
  36. page: OpenAI::Internal::CursorPage,
  37. model: OpenAI::Responses::ResponseItem,
  38. options: options
  39. )
  40. end
  41. # @api private
  42. #
  43. # @param client [OpenAI::Client]
  44. 1 def initialize(client:)
  45. 2 @client = client
  46. end
  47. end
  48. end
  49. end
  50. end

openai-ruby/lib/openai/resources/uploads.rb

66.67% lines covered

100.0% branches covered

15 relevant lines. 10 lines covered and 5 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Uploads
  5. # @return [OpenAI::Resources::Uploads::Parts]
  6. 1 attr_reader :parts
  7. # Some parameter documentations has been truncated, see
  8. # {OpenAI::Models::UploadCreateParams} for more details.
  9. #
  10. # Creates an intermediate
  11. # [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object
  12. # that you can add
  13. # [Parts](https://platform.openai.com/docs/api-reference/uploads/part-object) to.
  14. # Currently, an Upload can accept at most 8 GB in total and expires after an hour
  15. # after you create it.
  16. #
  17. # Once you complete the Upload, we will create a
  18. # [File](https://platform.openai.com/docs/api-reference/files/object) object that
  19. # contains all the parts you uploaded. This File is usable in the rest of our
  20. # platform as a regular File object.
  21. #
  22. # For certain `purpose` values, the correct `mime_type` must be specified. Please
  23. # refer to documentation for the
  24. # [supported MIME types for your use case](https://platform.openai.com/docs/assistants/tools/file-search#supported-files).
  25. #
  26. # For guidance on the proper filename extensions for each purpose, please follow
  27. # the documentation on
  28. # [creating a File](https://platform.openai.com/docs/api-reference/files/create).
  29. #
  30. # @overload create(bytes:, filename:, mime_type:, purpose:, request_options: {})
  31. #
  32. # @param bytes [Integer] The number of bytes in the file you are uploading.
  33. #
  34. # @param filename [String] The name of the file to upload.
  35. #
  36. # @param mime_type [String] The MIME type of the file.
  37. #
  38. # @param purpose [Symbol, OpenAI::Models::FilePurpose] The intended purpose of the uploaded file.
  39. #
  40. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  41. #
  42. # @return [OpenAI::Models::Upload]
  43. #
  44. # @see OpenAI::Models::UploadCreateParams
  45. 1 def create(params)
  46. parsed, options = OpenAI::UploadCreateParams.dump_request(params)
  47. @client.request(method: :post, path: "uploads", body: parsed, model: OpenAI::Upload, options: options)
  48. end
  49. # Some parameter documentations has been truncated, see
  50. # {OpenAI::Models::UploadCancelParams} for more details.
  51. #
  52. # Cancels the Upload. No Parts may be added after an Upload is cancelled.
  53. #
  54. # @overload cancel(upload_id, request_options: {})
  55. #
  56. # @param upload_id [String] The ID of the Upload.
  57. #
  58. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  59. #
  60. # @return [OpenAI::Models::Upload]
  61. #
  62. # @see OpenAI::Models::UploadCancelParams
  63. 1 def cancel(upload_id, params = {})
  64. @client.request(
  65. method: :post,
  66. path: ["uploads/%1$s/cancel", upload_id],
  67. model: OpenAI::Upload,
  68. options: params[:request_options]
  69. )
  70. end
  71. # Some parameter documentations has been truncated, see
  72. # {OpenAI::Models::UploadCompleteParams} for more details.
  73. #
  74. # Completes the
  75. # [Upload](https://platform.openai.com/docs/api-reference/uploads/object).
  76. #
  77. # Within the returned Upload object, there is a nested
  78. # [File](https://platform.openai.com/docs/api-reference/files/object) object that
  79. # is ready to use in the rest of the platform.
  80. #
  81. # You can specify the order of the Parts by passing in an ordered list of the Part
  82. # IDs.
  83. #
  84. # The number of bytes uploaded upon completion must match the number of bytes
  85. # initially specified when creating the Upload object. No Parts may be added after
  86. # an Upload is completed.
  87. #
  88. # @overload complete(upload_id, part_ids:, md5: nil, request_options: {})
  89. #
  90. # @param upload_id [String] The ID of the Upload.
  91. #
  92. # @param part_ids [Array<String>] The ordered list of Part IDs.
  93. #
  94. # @param md5 [String] The optional md5 checksum for the file contents to verify if the bytes uploaded
  95. #
  96. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  97. #
  98. # @return [OpenAI::Models::Upload]
  99. #
  100. # @see OpenAI::Models::UploadCompleteParams
  101. 1 def complete(upload_id, params)
  102. parsed, options = OpenAI::UploadCompleteParams.dump_request(params)
  103. @client.request(
  104. method: :post,
  105. path: ["uploads/%1$s/complete", upload_id],
  106. body: parsed,
  107. model: OpenAI::Upload,
  108. options: options
  109. )
  110. end
  111. # @api private
  112. #
  113. # @param client [OpenAI::Client]
  114. 1 def initialize(client:)
  115. 2 @client = client
  116. 2 @parts = OpenAI::Resources::Uploads::Parts.new(client: client)
  117. end
  118. end
  119. end
  120. end

openai-ruby/lib/openai/resources/uploads/parts.rb

77.78% lines covered

100.0% branches covered

9 relevant lines. 7 lines covered and 2 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class Uploads
  5. 1 class Parts
  6. # Some parameter documentations has been truncated, see
  7. # {OpenAI::Models::Uploads::PartCreateParams} for more details.
  8. #
  9. # Adds a
  10. # [Part](https://platform.openai.com/docs/api-reference/uploads/part-object) to an
  11. # [Upload](https://platform.openai.com/docs/api-reference/uploads/object) object.
  12. # A Part represents a chunk of bytes from the file you are trying to upload.
  13. #
  14. # Each Part can be at most 64 MB, and you can add Parts until you hit the Upload
  15. # maximum of 8 GB.
  16. #
  17. # It is possible to add multiple Parts in parallel. You can decide the intended
  18. # order of the Parts when you
  19. # [complete the Upload](https://platform.openai.com/docs/api-reference/uploads/complete).
  20. #
  21. # @overload create(upload_id, data:, request_options: {})
  22. #
  23. # @param upload_id [String] The ID of the Upload.
  24. #
  25. # @param data [Pathname, StringIO, IO, String, OpenAI::FilePart] The chunk of bytes for this Part.
  26. #
  27. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  28. #
  29. # @return [OpenAI::Models::Uploads::UploadPart]
  30. #
  31. # @see OpenAI::Models::Uploads::PartCreateParams
  32. 1 def create(upload_id, params)
  33. parsed, options = OpenAI::Uploads::PartCreateParams.dump_request(params)
  34. @client.request(
  35. method: :post,
  36. path: ["uploads/%1$s/parts", upload_id],
  37. headers: {"content-type" => "multipart/form-data"},
  38. body: parsed,
  39. model: OpenAI::Uploads::UploadPart,
  40. options: options
  41. )
  42. end
  43. # @api private
  44. #
  45. # @param client [OpenAI::Client]
  46. 1 def initialize(client:)
  47. 2 @client = client
  48. end
  49. end
  50. end
  51. end
  52. end

openai-ruby/lib/openai/resources/vector_stores.rb

60.0% lines covered

100.0% branches covered

25 relevant lines. 15 lines covered and 10 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class VectorStores
  5. # @return [OpenAI::Resources::VectorStores::Files]
  6. 1 attr_reader :files
  7. # @return [OpenAI::Resources::VectorStores::FileBatches]
  8. 1 attr_reader :file_batches
  9. # Some parameter documentations has been truncated, see
  10. # {OpenAI::Models::VectorStoreCreateParams} for more details.
  11. #
  12. # Create a vector store.
  13. #
  14. # @overload create(chunking_strategy: nil, expires_after: nil, file_ids: nil, metadata: nil, name: nil, request_options: {})
  15. #
  16. # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  17. #
  18. # @param expires_after [OpenAI::Models::VectorStoreCreateParams::ExpiresAfter] The expiration policy for a vector store.
  19. #
  20. # @param file_ids [Array<String>] A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
  21. #
  22. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  23. #
  24. # @param name [String] The name of the vector store.
  25. #
  26. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  27. #
  28. # @return [OpenAI::Models::VectorStore]
  29. #
  30. # @see OpenAI::Models::VectorStoreCreateParams
  31. 1 def create(params = {})
  32. parsed, options = OpenAI::VectorStoreCreateParams.dump_request(params)
  33. @client.request(
  34. method: :post,
  35. path: "vector_stores",
  36. body: parsed,
  37. model: OpenAI::VectorStore,
  38. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  39. )
  40. end
  41. # Retrieves a vector store.
  42. #
  43. # @overload retrieve(vector_store_id, request_options: {})
  44. #
  45. # @param vector_store_id [String] The ID of the vector store to retrieve.
  46. #
  47. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  48. #
  49. # @return [OpenAI::Models::VectorStore]
  50. #
  51. # @see OpenAI::Models::VectorStoreRetrieveParams
  52. 1 def retrieve(vector_store_id, params = {})
  53. @client.request(
  54. method: :get,
  55. path: ["vector_stores/%1$s", vector_store_id],
  56. model: OpenAI::VectorStore,
  57. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **params[:request_options].to_h}
  58. )
  59. end
  60. # Some parameter documentations has been truncated, see
  61. # {OpenAI::Models::VectorStoreUpdateParams} for more details.
  62. #
  63. # Modifies a vector store.
  64. #
  65. # @overload update(vector_store_id, expires_after: nil, metadata: nil, name: nil, request_options: {})
  66. #
  67. # @param vector_store_id [String] The ID of the vector store to modify.
  68. #
  69. # @param expires_after [OpenAI::Models::VectorStoreUpdateParams::ExpiresAfter, nil] The expiration policy for a vector store.
  70. #
  71. # @param metadata [Hash{Symbol=>String}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  72. #
  73. # @param name [String, nil] The name of the vector store.
  74. #
  75. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  76. #
  77. # @return [OpenAI::Models::VectorStore]
  78. #
  79. # @see OpenAI::Models::VectorStoreUpdateParams
  80. 1 def update(vector_store_id, params = {})
  81. parsed, options = OpenAI::VectorStoreUpdateParams.dump_request(params)
  82. @client.request(
  83. method: :post,
  84. path: ["vector_stores/%1$s", vector_store_id],
  85. body: parsed,
  86. model: OpenAI::VectorStore,
  87. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  88. )
  89. end
  90. # Some parameter documentations has been truncated, see
  91. # {OpenAI::Models::VectorStoreListParams} for more details.
  92. #
  93. # Returns a list of vector stores.
  94. #
  95. # @overload list(after: nil, before: nil, limit: nil, order: nil, request_options: {})
  96. #
  97. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  98. #
  99. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  100. #
  101. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  102. #
  103. # @param order [Symbol, OpenAI::Models::VectorStoreListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  104. #
  105. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  106. #
  107. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::VectorStore>]
  108. #
  109. # @see OpenAI::Models::VectorStoreListParams
  110. 1 def list(params = {})
  111. parsed, options = OpenAI::VectorStoreListParams.dump_request(params)
  112. @client.request(
  113. method: :get,
  114. path: "vector_stores",
  115. query: parsed,
  116. page: OpenAI::Internal::CursorPage,
  117. model: OpenAI::VectorStore,
  118. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  119. )
  120. end
  121. # Delete a vector store.
  122. #
  123. # @overload delete(vector_store_id, request_options: {})
  124. #
  125. # @param vector_store_id [String] The ID of the vector store to delete.
  126. #
  127. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  128. #
  129. # @return [OpenAI::Models::VectorStoreDeleted]
  130. #
  131. # @see OpenAI::Models::VectorStoreDeleteParams
  132. 1 def delete(vector_store_id, params = {})
  133. @client.request(
  134. method: :delete,
  135. path: ["vector_stores/%1$s", vector_store_id],
  136. model: OpenAI::VectorStoreDeleted,
  137. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **params[:request_options].to_h}
  138. )
  139. end
  140. # Some parameter documentations has been truncated, see
  141. # {OpenAI::Models::VectorStoreSearchParams} for more details.
  142. #
  143. # Search a vector store for relevant chunks based on a query and file attributes
  144. # filter.
  145. #
  146. # @overload search(vector_store_id, query:, filters: nil, max_num_results: nil, ranking_options: nil, rewrite_query: nil, request_options: {})
  147. #
  148. # @param vector_store_id [String] The ID of the vector store to search.
  149. #
  150. # @param query [String, Array<String>] A query string for a search
  151. #
  152. # @param filters [OpenAI::Models::ComparisonFilter, OpenAI::Models::CompoundFilter] A filter to apply based on file attributes.
  153. #
  154. # @param max_num_results [Integer] The maximum number of results to return. This number should be between 1 and 50
  155. #
  156. # @param ranking_options [OpenAI::Models::VectorStoreSearchParams::RankingOptions] Ranking options for search.
  157. #
  158. # @param rewrite_query [Boolean] Whether to rewrite the natural language query for vector search.
  159. #
  160. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  161. #
  162. # @return [OpenAI::Internal::Page<OpenAI::Models::VectorStoreSearchResponse>]
  163. #
  164. # @see OpenAI::Models::VectorStoreSearchParams
  165. 1 def search(vector_store_id, params)
  166. parsed, options = OpenAI::VectorStoreSearchParams.dump_request(params)
  167. @client.request(
  168. method: :post,
  169. path: ["vector_stores/%1$s/search", vector_store_id],
  170. body: parsed,
  171. page: OpenAI::Internal::Page,
  172. model: OpenAI::Models::VectorStoreSearchResponse,
  173. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  174. )
  175. end
  176. # @api private
  177. #
  178. # @param client [OpenAI::Client]
  179. 1 def initialize(client:)
  180. 2 @client = client
  181. 2 @files = OpenAI::Resources::VectorStores::Files.new(client: client)
  182. 2 @file_batches = OpenAI::Resources::VectorStores::FileBatches.new(client: client)
  183. end
  184. end
  185. end
  186. end

openai-ruby/lib/openai/resources/vector_stores/file_batches.rb

41.67% lines covered

100.0% branches covered

24 relevant lines. 10 lines covered and 14 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class VectorStores
  5. 1 class FileBatches
  6. # Some parameter documentations has been truncated, see
  7. # {OpenAI::Models::VectorStores::FileBatchCreateParams} for more details.
  8. #
  9. # Create a vector store file batch.
  10. #
  11. # @overload create(vector_store_id, file_ids:, attributes: nil, chunking_strategy: nil, request_options: {})
  12. #
  13. # @param vector_store_id [String] The ID of the vector store for which to create a File Batch.
  14. #
  15. # @param file_ids [Array<String>] A list of [File](https://platform.openai.com/docs/api-reference/files) IDs that
  16. #
  17. # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  18. #
  19. # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  20. #
  21. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  22. #
  23. # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch]
  24. #
  25. # @see OpenAI::Models::VectorStores::FileBatchCreateParams
  26. 1 def create(vector_store_id, params)
  27. parsed, options = OpenAI::VectorStores::FileBatchCreateParams.dump_request(params)
  28. @client.request(
  29. method: :post,
  30. path: ["vector_stores/%1$s/file_batches", vector_store_id],
  31. body: parsed,
  32. model: OpenAI::VectorStores::VectorStoreFileBatch,
  33. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  34. )
  35. end
  36. # Retrieves a vector store file batch.
  37. #
  38. # @overload retrieve(batch_id, vector_store_id:, request_options: {})
  39. #
  40. # @param batch_id [String] The ID of the file batch being retrieved.
  41. #
  42. # @param vector_store_id [String] The ID of the vector store that the file batch belongs to.
  43. #
  44. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  45. #
  46. # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch]
  47. #
  48. # @see OpenAI::Models::VectorStores::FileBatchRetrieveParams
  49. 1 def retrieve(batch_id, params)
  50. parsed, options = OpenAI::VectorStores::FileBatchRetrieveParams.dump_request(params)
  51. vector_store_id =
  52. parsed.delete(:vector_store_id) do
  53. raise ArgumentError.new("missing required path argument #{_1}")
  54. end
  55. @client.request(
  56. method: :get,
  57. path: ["vector_stores/%1$s/file_batches/%2$s", vector_store_id, batch_id],
  58. model: OpenAI::VectorStores::VectorStoreFileBatch,
  59. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  60. )
  61. end
  62. # Cancel a vector store file batch. This attempts to cancel the processing of
  63. # files in this batch as soon as possible.
  64. #
  65. # @overload cancel(batch_id, vector_store_id:, request_options: {})
  66. #
  67. # @param batch_id [String] The ID of the file batch to cancel.
  68. #
  69. # @param vector_store_id [String] The ID of the vector store that the file batch belongs to.
  70. #
  71. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  72. #
  73. # @return [OpenAI::Models::VectorStores::VectorStoreFileBatch]
  74. #
  75. # @see OpenAI::Models::VectorStores::FileBatchCancelParams
  76. 1 def cancel(batch_id, params)
  77. parsed, options = OpenAI::VectorStores::FileBatchCancelParams.dump_request(params)
  78. vector_store_id =
  79. parsed.delete(:vector_store_id) do
  80. raise ArgumentError.new("missing required path argument #{_1}")
  81. end
  82. @client.request(
  83. method: :post,
  84. path: ["vector_stores/%1$s/file_batches/%2$s/cancel", vector_store_id, batch_id],
  85. model: OpenAI::VectorStores::VectorStoreFileBatch,
  86. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  87. )
  88. end
  89. # Some parameter documentations has been truncated, see
  90. # {OpenAI::Models::VectorStores::FileBatchListFilesParams} for more details.
  91. #
  92. # Returns a list of vector store files in a batch.
  93. #
  94. # @overload list_files(batch_id, vector_store_id:, after: nil, before: nil, filter: nil, limit: nil, order: nil, request_options: {})
  95. #
  96. # @param batch_id [String] Path param: The ID of the file batch that the files belong to.
  97. #
  98. # @param vector_store_id [String] Path param: The ID of the vector store that the files belong to.
  99. #
  100. # @param after [String] Query param: A cursor for use in pagination. `after` is an object ID that define
  101. #
  102. # @param before [String] Query param: A cursor for use in pagination. `before` is an object ID that defin
  103. #
  104. # @param filter [Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Filter] Query param: Filter by file status. One of `in_progress`, `completed`, `failed`,
  105. #
  106. # @param limit [Integer] Query param: A limit on the number of objects to be returned. Limit can range be
  107. #
  108. # @param order [Symbol, OpenAI::Models::VectorStores::FileBatchListFilesParams::Order] Query param: Sort order by the `created_at` timestamp of the objects. `asc` for
  109. #
  110. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  111. #
  112. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::VectorStores::VectorStoreFile>]
  113. #
  114. # @see OpenAI::Models::VectorStores::FileBatchListFilesParams
  115. 1 def list_files(batch_id, params)
  116. parsed, options = OpenAI::VectorStores::FileBatchListFilesParams.dump_request(params)
  117. vector_store_id =
  118. parsed.delete(:vector_store_id) do
  119. raise ArgumentError.new("missing required path argument #{_1}")
  120. end
  121. @client.request(
  122. method: :get,
  123. path: ["vector_stores/%1$s/file_batches/%2$s/files", vector_store_id, batch_id],
  124. query: parsed,
  125. page: OpenAI::Internal::CursorPage,
  126. model: OpenAI::VectorStores::VectorStoreFile,
  127. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  128. )
  129. end
  130. # @api private
  131. #
  132. # @param client [OpenAI::Client]
  133. 1 def initialize(client:)
  134. 2 @client = client
  135. end
  136. end
  137. end
  138. end
  139. end

openai-ruby/lib/openai/resources/vector_stores/files.rb

37.5% lines covered

100.0% branches covered

32 relevant lines. 12 lines covered and 20 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 module Resources
  4. 1 class VectorStores
  5. 1 class Files
  6. # Some parameter documentations has been truncated, see
  7. # {OpenAI::Models::VectorStores::FileCreateParams} for more details.
  8. #
  9. # Create a vector store file by attaching a
  10. # [File](https://platform.openai.com/docs/api-reference/files) to a
  11. # [vector store](https://platform.openai.com/docs/api-reference/vector-stores/object).
  12. #
  13. # @overload create(vector_store_id, file_id:, attributes: nil, chunking_strategy: nil, request_options: {})
  14. #
  15. # @param vector_store_id [String] The ID of the vector store for which to create a File.
  16. #
  17. # @param file_id [String] A [File](https://platform.openai.com/docs/api-reference/files) ID that the vecto
  18. #
  19. # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Set of 16 key-value pairs that can be attached to an object. This can be
  20. #
  21. # @param chunking_strategy [OpenAI::Models::AutoFileChunkingStrategyParam, OpenAI::Models::StaticFileChunkingStrategyObjectParam] The chunking strategy used to chunk the file(s). If not set, will use the `auto`
  22. #
  23. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  24. #
  25. # @return [OpenAI::Models::VectorStores::VectorStoreFile]
  26. #
  27. # @see OpenAI::Models::VectorStores::FileCreateParams
  28. 1 def create(vector_store_id, params)
  29. parsed, options = OpenAI::VectorStores::FileCreateParams.dump_request(params)
  30. @client.request(
  31. method: :post,
  32. path: ["vector_stores/%1$s/files", vector_store_id],
  33. body: parsed,
  34. model: OpenAI::VectorStores::VectorStoreFile,
  35. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  36. )
  37. end
  38. # Retrieves a vector store file.
  39. #
  40. # @overload retrieve(file_id, vector_store_id:, request_options: {})
  41. #
  42. # @param file_id [String] The ID of the file being retrieved.
  43. #
  44. # @param vector_store_id [String] The ID of the vector store that the file belongs to.
  45. #
  46. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  47. #
  48. # @return [OpenAI::Models::VectorStores::VectorStoreFile]
  49. #
  50. # @see OpenAI::Models::VectorStores::FileRetrieveParams
  51. 1 def retrieve(file_id, params)
  52. parsed, options = OpenAI::VectorStores::FileRetrieveParams.dump_request(params)
  53. vector_store_id =
  54. parsed.delete(:vector_store_id) do
  55. raise ArgumentError.new("missing required path argument #{_1}")
  56. end
  57. @client.request(
  58. method: :get,
  59. path: ["vector_stores/%1$s/files/%2$s", vector_store_id, file_id],
  60. model: OpenAI::VectorStores::VectorStoreFile,
  61. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  62. )
  63. end
  64. # Some parameter documentations has been truncated, see
  65. # {OpenAI::Models::VectorStores::FileUpdateParams} for more details.
  66. #
  67. # Update attributes on a vector store file.
  68. #
  69. # @overload update(file_id, vector_store_id:, attributes:, request_options: {})
  70. #
  71. # @param file_id [String] Path param: The ID of the file to update attributes.
  72. #
  73. # @param vector_store_id [String] Path param: The ID of the vector store the file belongs to.
  74. #
  75. # @param attributes [Hash{Symbol=>String, Float, Boolean}, nil] Body param: Set of 16 key-value pairs that can be attached to an object. This ca
  76. #
  77. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  78. #
  79. # @return [OpenAI::Models::VectorStores::VectorStoreFile]
  80. #
  81. # @see OpenAI::Models::VectorStores::FileUpdateParams
  82. 1 def update(file_id, params)
  83. parsed, options = OpenAI::VectorStores::FileUpdateParams.dump_request(params)
  84. vector_store_id =
  85. parsed.delete(:vector_store_id) do
  86. raise ArgumentError.new("missing required path argument #{_1}")
  87. end
  88. @client.request(
  89. method: :post,
  90. path: ["vector_stores/%1$s/files/%2$s", vector_store_id, file_id],
  91. body: parsed,
  92. model: OpenAI::VectorStores::VectorStoreFile,
  93. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  94. )
  95. end
  96. # Some parameter documentations has been truncated, see
  97. # {OpenAI::Models::VectorStores::FileListParams} for more details.
  98. #
  99. # Returns a list of vector store files.
  100. #
  101. # @overload list(vector_store_id, after: nil, before: nil, filter: nil, limit: nil, order: nil, request_options: {})
  102. #
  103. # @param vector_store_id [String] The ID of the vector store that the files belong to.
  104. #
  105. # @param after [String] A cursor for use in pagination. `after` is an object ID that defines your place
  106. #
  107. # @param before [String] A cursor for use in pagination. `before` is an object ID that defines your place
  108. #
  109. # @param filter [Symbol, OpenAI::Models::VectorStores::FileListParams::Filter] Filter by file status. One of `in_progress`, `completed`, `failed`, `cancelled`.
  110. #
  111. # @param limit [Integer] A limit on the number of objects to be returned. Limit can range between 1 and 1
  112. #
  113. # @param order [Symbol, OpenAI::Models::VectorStores::FileListParams::Order] Sort order by the `created_at` timestamp of the objects. `asc` for ascending ord
  114. #
  115. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  116. #
  117. # @return [OpenAI::Internal::CursorPage<OpenAI::Models::VectorStores::VectorStoreFile>]
  118. #
  119. # @see OpenAI::Models::VectorStores::FileListParams
  120. 1 def list(vector_store_id, params = {})
  121. parsed, options = OpenAI::VectorStores::FileListParams.dump_request(params)
  122. @client.request(
  123. method: :get,
  124. path: ["vector_stores/%1$s/files", vector_store_id],
  125. query: parsed,
  126. page: OpenAI::Internal::CursorPage,
  127. model: OpenAI::VectorStores::VectorStoreFile,
  128. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  129. )
  130. end
  131. # Delete a vector store file. This will remove the file from the vector store but
  132. # the file itself will not be deleted. To delete the file, use the
  133. # [delete file](https://platform.openai.com/docs/api-reference/files/delete)
  134. # endpoint.
  135. #
  136. # @overload delete(file_id, vector_store_id:, request_options: {})
  137. #
  138. # @param file_id [String] The ID of the file to delete.
  139. #
  140. # @param vector_store_id [String] The ID of the vector store that the file belongs to.
  141. #
  142. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  143. #
  144. # @return [OpenAI::Models::VectorStores::VectorStoreFileDeleted]
  145. #
  146. # @see OpenAI::Models::VectorStores::FileDeleteParams
  147. 1 def delete(file_id, params)
  148. parsed, options = OpenAI::VectorStores::FileDeleteParams.dump_request(params)
  149. vector_store_id =
  150. parsed.delete(:vector_store_id) do
  151. raise ArgumentError.new("missing required path argument #{_1}")
  152. end
  153. @client.request(
  154. method: :delete,
  155. path: ["vector_stores/%1$s/files/%2$s", vector_store_id, file_id],
  156. model: OpenAI::VectorStores::VectorStoreFileDeleted,
  157. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  158. )
  159. end
  160. # Retrieve the parsed contents of a vector store file.
  161. #
  162. # @overload content(file_id, vector_store_id:, request_options: {})
  163. #
  164. # @param file_id [String] The ID of the file within the vector store.
  165. #
  166. # @param vector_store_id [String] The ID of the vector store.
  167. #
  168. # @param request_options [OpenAI::RequestOptions, Hash{Symbol=>Object}, nil]
  169. #
  170. # @return [OpenAI::Internal::Page<OpenAI::Models::VectorStores::FileContentResponse>]
  171. #
  172. # @see OpenAI::Models::VectorStores::FileContentParams
  173. 1 def content(file_id, params)
  174. parsed, options = OpenAI::VectorStores::FileContentParams.dump_request(params)
  175. vector_store_id =
  176. parsed.delete(:vector_store_id) do
  177. raise ArgumentError.new("missing required path argument #{_1}")
  178. end
  179. @client.request(
  180. method: :get,
  181. path: ["vector_stores/%1$s/files/%2$s/content", vector_store_id, file_id],
  182. page: OpenAI::Internal::Page,
  183. model: OpenAI::Models::VectorStores::FileContentResponse,
  184. options: {extra_headers: {"OpenAI-Beta" => "assistants=v2"}, **options}
  185. )
  186. end
  187. # @api private
  188. #
  189. # @param client [OpenAI::Client]
  190. 1 def initialize(client:)
  191. 2 @client = client
  192. end
  193. end
  194. end
  195. end
  196. end

openai-ruby/lib/openai/resources/webhooks.rb

21.95% lines covered

0.0% branches covered

41 relevant lines. 9 lines covered and 32 lines missed.
18 total branches, 0 branches covered and 18 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 require "openssl"
  3. 1 require "base64"
  4. 1 module OpenAI
  5. 1 module Resources
  6. 1 class Webhooks
  7. # Validates that the given payload was sent by OpenAI and parses the payload.
  8. #
  9. # @param payload [String] The raw webhook payload as a string
  10. # @param headers [Hash] The webhook headers
  11. # @param webhook_secret [String, nil] The webhook secret (optional, will use client webhook secret or ENV["OPENAI_WEBHOOK_SECRET"] if not provided)
  12. #
  13. # @return [OpenAI::Models::Webhooks::BatchCancelledWebhookEvent, OpenAI::Models::Webhooks::BatchCompletedWebhookEvent, OpenAI::Models::Webhooks::BatchExpiredWebhookEvent, OpenAI::Models::Webhooks::BatchFailedWebhookEvent, OpenAI::Models::Webhooks::EvalRunCanceledWebhookEvent, OpenAI::Models::Webhooks::EvalRunFailedWebhookEvent, OpenAI::Models::Webhooks::EvalRunSucceededWebhookEvent, OpenAI::Models::Webhooks::FineTuningJobCancelledWebhookEvent, OpenAI::Models::Webhooks::FineTuningJobFailedWebhookEvent, OpenAI::Models::Webhooks::FineTuningJobSucceededWebhookEvent, OpenAI::Models::Webhooks::ResponseCancelledWebhookEvent, OpenAI::Models::Webhooks::ResponseCompletedWebhookEvent, OpenAI::Models::Webhooks::ResponseCreatedWebhookEvent, OpenAI::Models::Webhooks::ResponseFailedWebhookEvent, OpenAI::Models::Webhooks::ResponseIncompleteWebhookEvent]
  14. #
  15. # @raise [ArgumentError] if signature verification fails
  16. 1 def unwrap(
  17. payload,
  18. headers = {},
  19. webhook_secret = @client.webhook_secret || ENV["OPENAI_WEBHOOK_SECRET"]
  20. )
  21. verify_signature(payload, headers, webhook_secret)
  22. parsed = JSON.parse(payload, symbolize_names: true)
  23. OpenAI::Internal::Type::Converter.coerce(OpenAI::Models::Webhooks::UnwrapWebhookEvent, parsed)
  24. end
  25. # Validates whether or not the webhook payload was sent by OpenAI.
  26. #
  27. # @param payload [String] The webhook payload as a string
  28. # @param headers [Hash] The webhook headers
  29. # @param webhook_secret [String, nil] The webhook secret (optional, will use client webhook secret or ENV["OPENAI_WEBHOOK_SECRET"] if not provided)
  30. # @param tolerance [Integer] Maximum age of the webhook in seconds (default: 300 = 5 minutes)
  31. #
  32. # @raise [ArgumentError] if the signature is invalid
  33. 1 def verify_signature(
  34. payload,
  35. headers,
  36. webhook_secret = @client.webhook_secret || ENV["OPENAI_WEBHOOK_SECRET"],
  37. tolerance = 300
  38. )
  39. then: 0 else: 0 if webhook_secret.nil?
  40. raise ArgumentError,
  41. "The webhook secret must either be set using the env var, OPENAI_WEBHOOK_SECRET, " \
  42. "or passed to this function"
  43. end
  44. # Extract required headers
  45. signature_header = headers["webhook-signature"] || headers[:webhook_signature]
  46. timestamp_header = headers["webhook-timestamp"] || headers[:webhook_timestamp]
  47. webhook_id = headers["webhook-id"] || headers[:webhook_id]
  48. then: 0 else: 0 if signature_header.nil?
  49. raise ArgumentError, "Missing required webhook-signature header"
  50. end
  51. then: 0 else: 0 if timestamp_header.nil?
  52. raise ArgumentError, "Missing required webhook-timestamp header"
  53. end
  54. then: 0 else: 0 if webhook_id.nil?
  55. raise ArgumentError, "Missing required webhook-id header"
  56. end
  57. # Validate timestamp to prevent replay attacks
  58. begin
  59. timestamp_seconds = timestamp_header.to_i
  60. rescue ArgumentError
  61. raise ArgumentError, "Invalid webhook timestamp format"
  62. end
  63. now = Time.now.to_i
  64. then: 0 else: 0 if now - timestamp_seconds > tolerance
  65. raise OpenAI::Errors::InvalidWebhookSignatureError, "Webhook timestamp is too old"
  66. end
  67. then: 0 else: 0 if timestamp_seconds > now + tolerance
  68. raise OpenAI::Errors::InvalidWebhookSignatureError, "Webhook timestamp is too new"
  69. end
  70. # Extract signatures from v1,<base64> format
  71. # The signature header can have multiple values, separated by spaces.
  72. # Each value is in the format v1,<base64>. We should accept if any match.
  73. signatures = signature_header.split.map do |part|
  74. then: 0 if part.start_with?("v1,")
  75. part[3..]
  76. else: 0 else
  77. part
  78. end
  79. end
  80. # Decode the secret if it starts with whsec_
  81. then: 0 decoded_secret = if webhook_secret.start_with?("whsec_")
  82. Base64.decode64(webhook_secret[6..])
  83. else: 0 else
  84. webhook_secret
  85. end
  86. # Create the signed payload: {webhook_id}.{timestamp}.{payload}
  87. signed_payload = "#{webhook_id}.#{timestamp_header}.#{payload}"
  88. # Compute HMAC-SHA256 signature
  89. expected_signature = Base64.encode64(
  90. OpenSSL::HMAC.digest("sha256", decoded_secret, signed_payload)
  91. ).strip
  92. # Accept if any signature matches using timing-safe comparison
  93. then: 0 else: 0 return if signatures.any? { |signature| OpenSSL.secure_compare(expected_signature, signature) }
  94. raise OpenAI::Errors::InvalidWebhookSignatureError,
  95. "The given webhook signature does not match the expected signature"
  96. end
  97. # @api private
  98. #
  99. # @param client [OpenAI::Client]
  100. 1 def initialize(client:)
  101. 2 @client = client
  102. end
  103. end
  104. end
  105. end

openai-ruby/lib/openai/streaming.rb

100.0% lines covered

100.0% branches covered

2 relevant lines. 2 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 Streaming = Helpers::Streaming
  4. end

openai-ruby/lib/openai/structured_output.rb

100.0% lines covered

100.0% branches covered

7 relevant lines. 7 lines covered and 0 lines missed.
0 total branches, 0 branches covered and 0 branches missed.
    
  1. # frozen_string_literal: true
  2. 1 module OpenAI
  3. 1 StructuredOutput = OpenAI::Helpers::StructuredOutput
  4. 1 ArrayOf = OpenAI::Helpers::StructuredOutput::ArrayOf
  5. 1 BaseModel = OpenAI::Helpers::StructuredOutput::BaseModel
  6. 1 Boolean = OpenAI::Helpers::StructuredOutput::Boolean
  7. 1 EnumOf = OpenAI::Helpers::StructuredOutput::EnumOf
  8. 1 UnionOf = OpenAI::Helpers::StructuredOutput::UnionOf
  9. end